Money_buy_simplex.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. *------Create thems Model------
  4. *------SCWPHP Version 1.0.0------
  5. *------Dev Model Jions------
  6. *------Create Time 2019-04-15 16:05:26------
  7. */
  8. namespace App\Commons\Model;
  9. use \System\Model;
  10. use Illuminate\Support\Facades\DB;
  11. class Money_buy_simplex extends Model {
  12. // 对象表
  13. protected $table = 'money_buy_simplex';
  14. public $timestamps = false;
  15. /**
  16. * 投注记录
  17. *
  18. * @access public
  19. * @param mixed $select 查询字段
  20. * @param mixed $where 查询条件
  21. * @param mixed $between 查询条件区间 ['money_time' => [$startTime, $endTime], ...]
  22. * @param mixed $begin 起始查询位置
  23. * @param mixed $pageSize 分页大小
  24. * @param mixed $toArray 是否专为数组
  25. * @param mixed $orderBy 排序字段
  26. * @param mixed $join 关联关系 ['article' => 'oney_buy.info_identity = article.identity', ...]
  27. * @return array JsonString
  28. */
  29. public function moneyBuySimplex($select, $where = '', $between = '', $begin = '', $pageSize = '', $toArray = 0, $orderBy = ['money_time' => 'desc'], $join = '') {
  30. // 查询字段
  31. $result = $this -> select($select);
  32. // 循环关联
  33. if (!empty($join)) {
  34. foreach ($join as $key => $value) {
  35. $result = $result -> join($key, $value);
  36. }
  37. }
  38. // 查询条件
  39. if (!empty($where)) {
  40. $result = $result -> where($where);
  41. }
  42. // 循环获取查询区间
  43. if (!empty($between)) {
  44. foreach ($between as $key => $value) {
  45. $result = $result -> whereBetween($key, $value);
  46. }
  47. }
  48. // 查询起始
  49. if (strlen($begin)) {
  50. $result = $result -> offset($begin);
  51. }
  52. // 分页大小
  53. if (strlen($pageSize)) {
  54. $result = $result -> limit($pageSize);
  55. }
  56. // 循环排序规则
  57. foreach ($orderBy as $key => $value) {
  58. $result = $result -> orderBy($key, $value);
  59. }
  60. // 获取数据
  61. $result = $result -> get();
  62. if ($toArray) {
  63. $result = $result -> toArray();
  64. }
  65. return $result;
  66. }
  67. }