Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
namespace calderawp\CalderaFormsQuery\Select;
abstract class ValueSelectQueryBuilder extends SelectQueryBuilder implements DoesSelectQueryByValue
{
/** @inheritdoc */
public function queryByFieldValue($fieldSlug, $fieldValue, $type = 'equals', $whereOperator = 'AND', $columns = [])
{
if (!empty($columns)) {
$this
->getSelectQuery()
->setColumns($columns);
}
switch ($type) {
case 'equals':
$this
->getSelectQuery()
->where($whereOperator)
->equals($this->getValueColumn(), $fieldValue);
break;
case 'notEquals':
$this->
getSelectQuery()
->where($whereOperator)
->notEquals($this->getValueColumn(), $fieldValue);
break;
case 'like':
$this->
getSelectQuery()
->where($whereOperator)
->like($this->getValueColumn(), $fieldValue);
break;
}
$this->isLike = 'like' === $type ? true : false;
if (!$this->isLike) {
$this->getSelectQuery()->where('AND')->equals('slug', $fieldSlug);
}
return $this;
}
}