StOdds.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. class StOdds extends Model {
  11. protected $table = '';
  12. /**
  13. * 获取赛事玩法是否还存在
  14. *
  15. * @access public
  16. * @param mixed $select 查询字段
  17. * @param mixed $wheres 查询条件
  18. * @param mixed $type 运动类型
  19. * @return array JsonString
  20. */
  21. public function stOdds($select, $wheres, $type) {
  22. $this->table = 'st_'. $type .'_odds';
  23. $count = count($wheres);
  24. $result = [];
  25. $unionAll = [];
  26. foreach ($wheres as $key => $value) {
  27. if ($key === 0) {
  28. $unionAll[0] = $this
  29. -> select($select)
  30. -> where($value);
  31. } elseif ($key + 1 === $count) {
  32. $result = $this
  33. -> select($select)
  34. -> where($value)
  35. -> unionAll($unionAll[$key - 1])
  36. -> get();
  37. } else {
  38. $unionAll[$key] = $this
  39. -> select($select)
  40. -> unionAll($unionAll[$key - 1])
  41. -> where($value);
  42. }
  43. }
  44. return $result;
  45. }
  46. }