Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
union.php
1<?php
12
19class Union
20{
22 protected $queries;
23
25 protected $order;
26
28 protected $limit;
29
31 protected $offset;
32
34 protected $connection;
35
37 {
38 $this->connection = $connection;
39 }
40
46 public function addQuery(UnionCondition $query)
47 {
48 $this->queries[] = $query;
49 return $this;
50 }
51
55 public function getQueries()
56 {
57 return $this->queries;
58 }
59
65 public function setOrder($order)
66 {
67 $this->order = array();
68
69 if (!is_array($order))
70 {
71 $order = array($order);
72 }
73
74 foreach ($order as $k => $v)
75 {
76 if (is_numeric($k))
77 {
78 $this->addOrder($v);
79 }
80 else
81 {
82 $this->addOrder($k, $v);
83 }
84 }
85
86 return $this;
87 }
88
96 public function addOrder($definition, $order = 'ASC')
97 {
98 $order = strtoupper($order);
99
100 if (!in_array($order, array('ASC', 'DESC'), true))
101 {
102 throw new ArgumentException(sprintf('Invalid order "%s"', $order));
103 }
104
105 $helper = $this->connection->getSqlHelper();
106
107 if ($order == 'ASC')
108 {
109 $order = $helper->getAscendingOrder();
110 }
111 else
112 {
113 $order = $helper->getDescendingOrder();
114 }
115
116 $this->order[$definition] = $order;
117
118 return $this;
119 }
120
124 public function getOrder()
125 {
126 return $this->order;
127 }
128
134 public function setLimit($limit)
135 {
136 $this->limit = $limit;
137 return $this;
138 }
139
143 public function getLimit()
144 {
145 return $this->limit;
146 }
147
153 public function setOffset($offset)
154 {
155 $this->offset = $offset;
156 return $this;
157 }
158
162 public function getOffset()
163 {
164 return $this->offset;
165 }
166}
__construct(Connection $connection)
Definition union.php:36
addOrder($definition, $order='ASC')
Definition union.php:96
addQuery(UnionCondition $query)
Definition union.php:46