<?php
/**
*------Create thems Model------
*------SCWPHP  Version 1.0.0------
*------Dev Model Jions------
*------Create Time 2019-04-15 16:05:26------
*/
namespace App\Commons\Model;

use \System\Model;

class St_competition extends Model {

    // 对象表
    protected $table = '';
    public $timestamps = false;

    /**
     * 投注记录
     *
     * @access public
     * @param mixed $type 查询字段
     * @param mixed $moneyBuyWhere 查询条件
     * @param mixed $moneyBuyBetween 查询条件区间
     * @param mixed $begin 起始查询位置
     * @param mixed $pageSize 分页大小
     * @param mixed $orderBy 排序字段
     * @return array JsonString
     */
    public function getMatch($type, $whereOr) {
        $this->table = 'st_' . $type . '_competition';
        $stLeague = 'st_' . $type . '_league';
        if ($whereOr) {
            $result = $this
                ->select(['match_date', $this->table.'.id', 'match_time', 'name_chinese'])
                ->join($stLeague,$stLeague.'.id','=',$this->table.'.lg_id')
                -> where([$this->table.'.id' => $whereOr[0]]);
            foreach ($whereOr as $key => $value) {
                if ($key > 0) {
                    $result = $result -> orWhere([$this->table.'.id' => $value]);
                }
            }
            $result = $result -> get();
        } else {
            $result = [];
        }

        return $result;
    }
}
