<?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 Money_buy extends Model {

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

    /**
     * 投注记录
     *
     * @access public
     * @param mixed $select 查询字段
     * @param mixed $moneyBuyWhere 查询条件
     * @param mixed $moneyBuyBetween 查询条件区间
     * @param mixed $begin 起始查询位置
     * @param mixed $pageSize 分页大小
     * @param mixed $orderBy 排序字段
     * @return array JsonString
     */
    public function moneyBuy($select, $moneyBuyWhere, $moneyBuyBetween, $begin, $pageSize, $orderBy = 'money_time') {
        $result = $this
            //-> join('article','money_buy.info_identity','=','article.identity')
            -> select($select)
            -> where($moneyBuyWhere)
            -> whereBetween('money_time', $moneyBuyBetween)
            -> offset($begin)
            -> limit($pageSize)
            -> orderBy($orderBy)
            -> get();

        return $result;
    }

    /**
     * 投注记录总数
     *
     * @access public
     * @param mixed $moneyBuyWhere 查询条件
     * @param mixed $moneyBuyBetween 查询条件区间
     * @return array JsonString
     */
    public function moneyBuyTotal($moneyBuyWhere, $moneyBuyBetween) {
        $result = $this
            -> where($moneyBuyWhere)
            -> whereBetween('money_time', $moneyBuyBetween)
            -> count();

        return $result;
    }
}
