| @@ 12-40 (lines=29) @@ | ||
| 9 | * @property string $table |
|
| 10 | * @property WhereInterface $query |
|
| 11 | */ |
|
| 12 | trait OrWhereMethod |
|
| 13 | { |
|
| 14 | /** |
|
| 15 | * @param mixed $where |
|
| 16 | * |
|
| 17 | * @return static |
|
| 18 | * |
|
| 19 | * @throws LogicException |
|
| 20 | */ |
|
| 21 | public function orWhere($where) |
|
| 22 | { |
|
| 23 | if (!isset($this->query)) { |
|
| 24 | throw new LogicException("orWhere() called before select(), update() or delete()"); |
|
| 25 | } |
|
| 26 | ||
| 27 | $query = clone $this->query; |
|
| 28 | call_user_func_array([$query, "orWhere"], func_get_args()); |
|
| 29 | ||
| 30 | return $this->cloneWith("query", $query); |
|
| 31 | } |
|
| 32 | ||
| 33 | /** |
|
| 34 | * @param string $key |
|
| 35 | * @param mixed $value |
|
| 36 | * |
|
| 37 | * @return static |
|
| 38 | */ |
|
| 39 | abstract protected function cloneWith($key, $value); |
|
| 40 | } |
|
| 41 | ||
| @@ 12-40 (lines=29) @@ | ||
| 9 | * @property string $table |
|
| 10 | * @property WhereInterface $query |
|
| 11 | */ |
|
| 12 | trait WhereMethod |
|
| 13 | { |
|
| 14 | /** |
|
| 15 | * @param mixed $where |
|
| 16 | * |
|
| 17 | * @return static |
|
| 18 | * |
|
| 19 | * @throws LogicException |
|
| 20 | */ |
|
| 21 | public function where($where) |
|
| 22 | { |
|
| 23 | if (!isset($this->query)) { |
|
| 24 | throw new LogicException("where() called before select(), update() or delete()"); |
|
| 25 | } |
|
| 26 | ||
| 27 | $query = clone $this->query; |
|
| 28 | call_user_func_array([$query, "where"], func_get_args()); |
|
| 29 | ||
| 30 | return $this->cloneWith("query", $query); |
|
| 31 | } |
|
| 32 | ||
| 33 | /** |
|
| 34 | * @param string $key |
|
| 35 | * @param mixed $value |
|
| 36 | * |
|
| 37 | * @return static |
|
| 38 | */ |
|
| 39 | abstract protected function cloneWith($key, $value); |
|
| 40 | } |
|
| 41 | ||