Bindings.php
1.49 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
namespace ACP\Search\Query;
class Bindings
{
/**
* @var int[]
*/
private static $aliases = [];
protected $where = '';
protected $join = '';
protected $group_by = '';
protected $order_by = '';
protected $meta_query = [];
public function get_unique_alias(string $column): string
{
if ( ! isset(self::$aliases[$column])) {
self::$aliases[$column] = 0;
}
return $column . '_ac' . self::$aliases[$column]++;
}
public function get_where(): string
{
return $this->where;
}
public function where(string $where): self
{
$this->where = $where;
return $this;
}
public function get_join(): string
{
return $this->join;
}
public function join(string $join): self
{
$this->join = $join;
return $this;
}
public function get_group_by(): string
{
return $this->group_by;
}
public function group_by(string $group): self
{
$this->group_by = $group;
return $this;
}
public function get_order_by(): string
{
return $this->order_by;
}
public function order_by(string $order_by): self
{
$this->order_by = $order_by;
return $this;
}
public function get_meta_query(): array
{
return $this->meta_query;
}
public function meta_query(array $args): self
{
$this->meta_query = $args;
return $this;
}
}