sanderdekroon /
parlant
| 1 | <?php |
||||||||
| 2 | |||||||||
| 3 | namespace Sanderdekroon\Parlant\Builder; |
||||||||
| 4 | |||||||||
| 5 | use Closure; |
||||||||
| 6 | use InvalidArgumentException; |
||||||||
| 7 | |||||||||
| 8 | trait QueriesMeta |
||||||||
| 9 | { |
||||||||
| 10 | /** |
||||||||
| 11 | * Query the meta values (custom post fields) of posts. |
||||||||
| 12 | * @param string|array|Closure $column The field name, an array of where clauses or an Closure detailing a nested where clause. |
||||||||
| 13 | * @param string $operator |
||||||||
| 14 | * @param mixed $value |
||||||||
| 15 | * @param string $type The type comparison, for example NUMERIC or CHAR |
||||||||
| 16 | * @param string $relation AND/OR, currently unimplemented |
||||||||
| 17 | * @param integer $level The query level, currently unimplemented |
||||||||
| 18 | * @return $this |
||||||||
| 19 | */ |
||||||||
| 20 | 8 | public function whereMeta($column, $operator = null, $value = null, $type = null, $relation = null, $level = 1) |
|||||||
| 21 | { |
||||||||
| 22 | 8 | $clause = new WhereMetaClause($this->getGrammar()); |
|||||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||||
| 23 | |||||||||
| 24 | 8 | foreach ($clause->build($column, $operator, $value, $type, $relation, $level) as $where) { |
|||||||
| 25 | 7 | $this->appendBinding('whereMetas', $where); |
|||||||
|
0 ignored issues
–
show
It seems like
appendBinding() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||||
| 26 | } |
||||||||
| 27 | |||||||||
| 28 | 7 | $this->setBinding('whereMetaRelation', $clause->getRelation() + ($this->getBinding('whereMetaRelation') ?: [1 => 'AND'])); |
|||||||
|
0 ignored issues
–
show
It seems like
getBinding() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
It seems like
setBinding() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||||
| 29 | |||||||||
| 30 | 7 | return $this; |
|||||||
| 31 | } |
||||||||
| 32 | |||||||||
| 33 | /** |
||||||||
| 34 | * Query the meta values (custom post fields) of posts and set the relation to OR |
||||||||
| 35 | * @param string $column The field name |
||||||||
| 36 | * @param string $operator |
||||||||
| 37 | * @param mixed $value |
||||||||
| 38 | * @param string $type The type comparison, for example NUMERIC or CHAR |
||||||||
| 39 | * @param integer $level The query level, currently unimplemented |
||||||||
| 40 | * @return $this |
||||||||
| 41 | */ |
||||||||
| 42 | 1 | public function orWhereMeta($column, $operator = null, $value = null, $type = null, $level = 1) |
|||||||
| 43 | { |
||||||||
| 44 | 1 | return $this->whereMeta($column, $operator, $value, $type, 'OR', $level); |
|||||||
| 45 | } |
||||||||
| 46 | } |
||||||||
| 47 |