| @@ 6-29 (lines=24) @@ | ||
| 3 | ||
| 4 | use Kir\MySQL\Builder\Internal\ConditionBuilder; |
|
| 5 | ||
| 6 | trait HavingBuilder { |
|
| 7 | use AbstractDB; |
|
| 8 | ||
| 9 | /** @var array */ |
|
| 10 | private $having = array(); |
|
| 11 | ||
| 12 | /** |
|
| 13 | * @param string $expression |
|
| 14 | * @param mixed ...$param |
|
| 15 | * @return $this |
|
| 16 | */ |
|
| 17 | public function having($expression) { |
|
| 18 | $this->having[] = array($expression, array_slice(func_get_args(), 1)); |
|
| 19 | return $this; |
|
| 20 | } |
|
| 21 | ||
| 22 | /** |
|
| 23 | * @param string $query |
|
| 24 | * @return string |
|
| 25 | */ |
|
| 26 | protected function buildHavingConditions($query) { |
|
| 27 | return ConditionBuilder::build($this->db(), $query, $this->having, 'HAVING'); |
|
| 28 | } |
|
| 29 | } |
|
| 30 | ||
| @@ 6-29 (lines=24) @@ | ||
| 3 | ||
| 4 | use Kir\MySQL\Builder\Internal\ConditionBuilder; |
|
| 5 | ||
| 6 | trait WhereBuilder { |
|
| 7 | use AbstractDB; |
|
| 8 | ||
| 9 | /** @var array */ |
|
| 10 | private $where = array(); |
|
| 11 | ||
| 12 | /** |
|
| 13 | * @param string $expression |
|
| 14 | * @param mixed ...$param |
|
| 15 | * @return $this |
|
| 16 | */ |
|
| 17 | public function where($expression) { |
|
| 18 | $this->where[] = [$expression, array_slice(func_get_args(), 1)]; |
|
| 19 | return $this; |
|
| 20 | } |
|
| 21 | ||
| 22 | /** |
|
| 23 | * @param string $query |
|
| 24 | * @return string |
|
| 25 | */ |
|
| 26 | protected function buildWhereConditions($query) { |
|
| 27 | return ConditionBuilder::build($this->db(), $query, $this->where, 'WHERE'); |
|
| 28 | } |
|
| 29 | } |
|
| 30 | ||