table = 'st_'. $type .'_odds'; $count = count($wheres); $result = []; $unionAll = []; foreach ($wheres as $key => $value) { if ($key === 0) { $unionAll[0] = $this -> select($select) -> where($value); } elseif ($key + 1 === $count) { $result = $this -> select($select) -> where($value) -> unionAll($unionAll[$key - 1]) -> get(); } else { $unionAll[$key] = $this -> select($select) -> unionAll($unionAll[$key - 1]) -> where($value); } } return $result; } }