Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
6a488035 TO |
2 | /* |
3 | +--------------------------------------------------------------------+ | |
7e9e8871 | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
0f03f337 | 6 | | Copyright CiviCRM LLC (c) 2004-2017 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * | |
31 | * @package CRM | |
0f03f337 | 32 | * @copyright CiviCRM LLC (c) 2004-2017 |
6a488035 TO |
33 | */ |
34 | class CRM_Core_BAO_CustomQuery { | |
7da04cde | 35 | const PREFIX = 'custom_value_'; |
6a488035 TO |
36 | |
37 | /** | |
d2e5d2ce | 38 | * The set of custom field ids. |
6a488035 TO |
39 | * |
40 | * @var array | |
41 | */ | |
42 | protected $_ids; | |
43 | ||
44 | /** | |
d2e5d2ce | 45 | * The select clause. |
6a488035 TO |
46 | * |
47 | * @var array | |
48 | */ | |
49 | public $_select; | |
50 | ||
51 | /** | |
d2e5d2ce | 52 | * The name of the elements that are in the select clause. |
6a488035 TO |
53 | * used to extract the values |
54 | * | |
55 | * @var array | |
56 | */ | |
57 | public $_element; | |
58 | ||
59 | /** | |
d2e5d2ce | 60 | * The tables involved in the query. |
6a488035 TO |
61 | * |
62 | * @var array | |
63 | */ | |
64 | public $_tables; | |
65 | public $_whereTables; | |
66 | ||
67 | /** | |
d2e5d2ce | 68 | * The where clause. |
6a488035 TO |
69 | * |
70 | * @var array | |
71 | */ | |
72 | public $_where; | |
73 | ||
74 | /** | |
d2e5d2ce | 75 | * The english language version of the query. |
6a488035 TO |
76 | * |
77 | * @var array | |
78 | */ | |
79 | public $_qill; | |
80 | ||
81 | /** | |
b4fb2d23 CW |
82 | * @deprecated |
83 | * No longer needed due to CRM-17646 refactoring, but still used in some places | |
6a488035 TO |
84 | * |
85 | * @var array | |
86 | */ | |
87 | public $_options; | |
88 | ||
89 | /** | |
d2e5d2ce | 90 | * The custom fields information. |
6a488035 TO |
91 | * |
92 | * @var array | |
93 | */ | |
94 | public $_fields; | |
95 | ||
96 | /** | |
97 | * Searching for contacts? | |
98 | * | |
99 | * @var boolean | |
100 | */ | |
101 | protected $_contactSearch; | |
102 | ||
247ad911 | 103 | protected $_locationSpecificCustomFields; |
442df34b | 104 | |
6a488035 | 105 | /** |
d2e5d2ce | 106 | * This stores custom data group types and tables that it extends. |
6a488035 TO |
107 | * |
108 | * @var array | |
6a488035 TO |
109 | */ |
110 | static $extendsMap = array( | |
111 | 'Contact' => 'civicrm_contact', | |
112 | 'Individual' => 'civicrm_contact', | |
113 | 'Household' => 'civicrm_contact', | |
114 | 'Organization' => 'civicrm_contact', | |
115 | 'Contribution' => 'civicrm_contribution', | |
95974e8e | 116 | 'ContributionRecur' => 'civicrm_contribution_recur', |
6a488035 TO |
117 | 'Membership' => 'civicrm_membership', |
118 | 'Participant' => 'civicrm_participant', | |
119 | 'Group' => 'civicrm_group', | |
120 | 'Relationship' => 'civicrm_relationship', | |
121 | 'Event' => 'civicrm_event', | |
122 | 'Case' => 'civicrm_case', | |
123 | 'Activity' => 'civicrm_activity', | |
124 | 'Pledge' => 'civicrm_pledge', | |
125 | 'Grant' => 'civicrm_grant', | |
126 | 'Address' => 'civicrm_address', | |
5b37ca7b EM |
127 | 'Campaign' => 'civicrm_campaign', |
128 | 'Survey' => 'civicrm_survey', | |
6a488035 TO |
129 | ); |
130 | ||
131 | /** | |
d2e5d2ce | 132 | * Class constructor. |
6a488035 TO |
133 | * |
134 | * Takes in a set of custom field ids andsets up the data structures to | |
135 | * generate a query | |
136 | * | |
6a0b768e TO |
137 | * @param array $ids |
138 | * The set of custom field ids. | |
fd31fa4c EM |
139 | * |
140 | * @param bool $contactSearch | |
141 | * @param array $locationSpecificFields | |
442df34b | 142 | */ |
00be9182 | 143 | public function __construct($ids, $contactSearch = FALSE, $locationSpecificFields = array()) { |
6a488035 | 144 | $this->_ids = &$ids; |
247ad911 | 145 | $this->_locationSpecificCustomFields = $locationSpecificFields; |
6a488035 | 146 | |
353ffa53 TO |
147 | $this->_select = array(); |
148 | $this->_element = array(); | |
149 | $this->_tables = array(); | |
6a488035 | 150 | $this->_whereTables = array(); |
353ffa53 TO |
151 | $this->_where = array(); |
152 | $this->_qill = array(); | |
153 | $this->_options = array(); | |
6a488035 TO |
154 | |
155 | $this->_fields = array(); | |
156 | $this->_contactSearch = $contactSearch; | |
157 | ||
158 | if (empty($this->_ids)) { | |
159 | return; | |
160 | } | |
161 | ||
162 | // initialize the field array | |
163 | $tmpArray = array_keys($this->_ids); | |
164 | $idString = implode(',', $tmpArray); | |
353ffa53 | 165 | $query = " |
6a488035 TO |
166 | SELECT f.id, f.label, f.data_type, |
167 | f.html_type, f.is_search_range, | |
168 | f.option_group_id, f.custom_group_id, | |
169 | f.column_name, g.table_name, | |
170 | f.date_format,f.time_format | |
171 | FROM civicrm_custom_field f, | |
172 | civicrm_custom_group g | |
173 | WHERE f.custom_group_id = g.id | |
174 | AND g.is_active = 1 | |
175 | AND f.is_active = 1 | |
176 | AND f.id IN ( $idString )"; | |
177 | ||
178 | $dao = CRM_Core_DAO::executeQuery($query); | |
179 | while ($dao->fetch()) { | |
180 | // get the group dao to figure which class this custom field extends | |
181 | $extends = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $dao->custom_group_id, 'extends'); | |
182 | if (array_key_exists($extends, self::$extendsMap)) { | |
183 | $extendsTable = self::$extendsMap[$extends]; | |
184 | } | |
185 | elseif (in_array($extends, CRM_Contact_BAO_ContactType::subTypes())) { | |
186 | // if $extends is a subtype, refer contact table | |
187 | $extendsTable = self::$extendsMap['Contact']; | |
188 | } | |
189 | $this->_fields[$dao->id] = array( | |
190 | 'id' => $dao->id, | |
191 | 'label' => $dao->label, | |
192 | 'extends' => $extendsTable, | |
193 | 'data_type' => $dao->data_type, | |
194 | 'html_type' => $dao->html_type, | |
195 | 'is_search_range' => $dao->is_search_range, | |
196 | 'column_name' => $dao->column_name, | |
197 | 'table_name' => $dao->table_name, | |
198 | 'option_group_id' => $dao->option_group_id, | |
199 | ); | |
200 | ||
b4fb2d23 CW |
201 | // Deprecated (and poorly named) cache of field attributes |
202 | $this->_options[$dao->id] = array( | |
203 | 'attributes' => array( | |
204 | 'label' => $dao->label, | |
205 | 'data_type' => $dao->data_type, | |
206 | 'html_type' => $dao->html_type, | |
207 | ), | |
75cda526 CW |
208 | ); |
209 | ||
210 | $options = CRM_Core_PseudoConstant::get('CRM_Core_BAO_CustomField', 'custom_' . $dao->id, array(), 'search'); | |
211 | if ($options) { | |
212 | $this->_options[$dao->id] += $options; | |
213 | } | |
6a488035 | 214 | |
b4fb2d23 | 215 | if ($dao->html_type == 'Select Date') { |
6a488035 TO |
216 | $this->_options[$dao->id]['attributes']['date_format'] = $dao->date_format; |
217 | $this->_options[$dao->id]['attributes']['time_format'] = $dao->time_format; | |
218 | } | |
6a488035 TO |
219 | } |
220 | } | |
221 | ||
222 | /** | |
d2e5d2ce | 223 | * Generate the select clause and the associated tables. |
6a488035 | 224 | */ |
00be9182 | 225 | public function select() { |
6a488035 TO |
226 | if (empty($this->_fields)) { |
227 | return; | |
228 | } | |
229 | ||
230 | foreach ($this->_fields as $id => $field) { | |
231 | $name = $field['table_name']; | |
232 | $fieldName = 'custom_' . $field['id']; | |
233 | $this->_select["{$name}_id"] = "{$name}.id as {$name}_id"; | |
234 | $this->_element["{$name}_id"] = 1; | |
235 | $this->_select[$fieldName] = "{$field['table_name']}.{$field['column_name']} as $fieldName"; | |
236 | $this->_element[$fieldName] = 1; | |
237 | $joinTable = NULL; | |
dcf0d348 PJ |
238 | // CRM-14265 |
239 | if ($field['extends'] == 'civicrm_group') { | |
240 | return; | |
241 | } | |
242 | elseif ($field['extends'] == 'civicrm_contact') { | |
6a488035 TO |
243 | $joinTable = 'contact_a'; |
244 | } | |
245 | elseif ($field['extends'] == 'civicrm_contribution') { | |
dcf0d348 | 246 | $joinTable = $field['extends']; |
6a488035 | 247 | } |
dcf0d348 PJ |
248 | elseif (in_array($field['extends'], self::$extendsMap)) { |
249 | $joinTable = $field['extends']; | |
6a488035 | 250 | } |
dcf0d348 PJ |
251 | else { |
252 | return; | |
6a488035 | 253 | } |
dcf0d348 PJ |
254 | |
255 | $this->_tables[$name] = "\nLEFT JOIN $name ON $name.entity_id = $joinTable.id"; | |
256 | ||
257 | if ($this->_ids[$id]) { | |
258 | $this->_whereTables[$name] = $this->_tables[$name]; | |
6a488035 TO |
259 | } |
260 | ||
261 | if ($joinTable) { | |
442df34b CW |
262 | $joinClause = 1; |
263 | $joinTableAlias = $joinTable; | |
264 | // Set location-specific query | |
247ad911 | 265 | if (isset($this->_locationSpecificCustomFields[$id])) { |
266 | list($locationType, $locationTypeId) = $this->_locationSpecificCustomFields[$id]; | |
442df34b CW |
267 | $joinTableAlias = "$locationType-address"; |
268 | $joinClause = "\nLEFT JOIN $joinTable `$locationType-address` ON (`$locationType-address`.contact_id = contact_a.id AND `$locationType-address`.location_type_id = $locationTypeId)"; | |
269 | } | |
270 | $this->_tables[$name] = "\nLEFT JOIN $name ON $name.entity_id = `$joinTableAlias`.id"; | |
6a488035 TO |
271 | if ($this->_ids[$id]) { |
272 | $this->_whereTables[$name] = $this->_tables[$name]; | |
273 | } | |
274 | if ($joinTable != 'contact_a') { | |
442df34b | 275 | $this->_whereTables[$joinTableAlias] = $this->_tables[$joinTableAlias] = $joinClause; |
6a488035 TO |
276 | } |
277 | elseif ($this->_contactSearch) { | |
278 | CRM_Contact_BAO_Query::$_openedPanes[ts('Custom Fields')] = TRUE; | |
279 | } | |
280 | } | |
281 | } | |
282 | } | |
283 | ||
284 | /** | |
192d36c5 | 285 | * Generate the where clause and also the english language equivalent. |
6a488035 | 286 | */ |
00be9182 | 287 | public function where() { |
6a488035 TO |
288 | foreach ($this->_ids as $id => $values) { |
289 | ||
192d36c5 | 290 | // Fixed for Issue CRM 607 |
6a488035 TO |
291 | if (CRM_Utils_Array::value($id, $this->_fields) === NULL || |
292 | !$values | |
293 | ) { | |
294 | continue; | |
295 | } | |
296 | ||
297 | $strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower'; | |
298 | ||
299 | foreach ($values as $tuple) { | |
300 | list($name, $op, $value, $grouping, $wildcard) = $tuple; | |
301 | ||
6a488035 | 302 | $field = $this->_fields[$id]; |
6a488035 | 303 | |
3130209f CW |
304 | $fieldName = "{$field['table_name']}.{$field['column_name']}"; |
305 | ||
05c5cbc8 | 306 | $isSerialized = CRM_Core_BAO_CustomField::isSerialized($field); |
307 | ||
3130209f | 308 | // fix $value here to escape sql injection attacks |
7ecb613a | 309 | $qillValue = NULL; |
9f388466 CW |
310 | if (!is_array($value)) { |
311 | $value = CRM_Core_DAO::escapeString(trim($value)); | |
8cee0c70 | 312 | $qillValue = CRM_Core_BAO_CustomField::displayValue($value, $id); |
7ecb613a | 313 | } |
314 | elseif (count($value) && in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) { | |
315 | $op = key($value); | |
8cee0c70 | 316 | $qillValue = strstr($op, 'NULL') ? NULL : CRM_Core_BAO_CustomField::displayValue($value[$op], $id); |
9f388466 | 317 | } |
c94d39fd | 318 | else { |
ec28b24d | 319 | $op = strstr($op, 'IN') ? $op : 'IN'; |
8cee0c70 | 320 | $qillValue = CRM_Core_BAO_CustomField::displayValue($value, $id); |
c94d39fd | 321 | } |
3130209f | 322 | |
2c261619 | 323 | $qillOp = CRM_Utils_Array::value($op, CRM_Core_SelectValues::getSearchBuilderOperators(), $op); |
3130209f | 324 | |
6a488035 TO |
325 | switch ($field['data_type']) { |
326 | case 'String': | |
16b6d3d4 | 327 | case 'StateProvince': |
328 | case 'Country': | |
3130209f CW |
329 | |
330 | if ($field['is_search_range'] && is_array($value)) { | |
4c2fe77b | 331 | //didn't found any field under any of these three data-types as searchable by range |
6a488035 TO |
332 | } |
333 | else { | |
05c5cbc8 | 334 | // fix $value here to escape sql injection attacks |
335 | if (!is_array($value)) { | |
16b6d3d4 | 336 | if ($field['data_type'] == 'String') { |
337 | $value = CRM_Utils_Type::escape($strtolower($value), 'String'); | |
338 | } | |
339 | else { | |
340 | $value = CRM_Utils_Type::escape($value, 'Integer'); | |
341 | } | |
2f32a341 | 342 | $value = str_replace(array('[', ']', ','), array('\[', '\]', '[:comma:]'), $value); |
343 | $value = str_replace('|', '[:separator:]', $value); | |
05c5cbc8 | 344 | } |
c94d39fd | 345 | elseif ($isSerialized) { |
346 | if (in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) { | |
347 | $op = key($value); | |
348 | $value = $value[$op]; | |
349 | } | |
7bcee799 | 350 | // CRM-19006: escape characters like comma, | before building regex pattern |
351 | $value = (array) $value; | |
352 | foreach ($value as $key => $val) { | |
894223d8 | 353 | $value[$key] = str_replace(array('[', ']', ','), array('\[', '\]', '[:comma:]'), $val); |
354 | $value[$key] = str_replace('|', '[:separator:]', $value[$key]); | |
7bcee799 | 355 | } |
356 | $value = implode(',', $value); | |
05c5cbc8 | 357 | } |
3130209f | 358 | |
2c261619 | 359 | // CRM-14563,CRM-16575 : Special handling of multi-select custom fields |
78fe145d | 360 | if ($isSerialized && !CRM_Utils_System::isNull($value) && !strstr($op, 'NULL') && !strstr($op, 'LIKE')) { |
528f09a1 | 361 | $sp = CRM_Core_DAO::VALUE_SEPARATOR; |
2f32a341 | 362 | $value = str_replace(",", "$sp|$sp", $value); |
363 | $value = str_replace(array('[:comma:]', '(', ')'), array(',', '[[.left-parenthesis.]]', '[[.right-parenthesis.]]'), $value); | |
364 | ||
c94d39fd | 365 | $op = (strstr($op, '!') || strstr($op, 'NOT')) ? 'NOT RLIKE' : 'RLIKE'; |
528f09a1 | 366 | $value = $sp . $value . $sp; |
c94d39fd | 367 | if (!$wildcard) { |
528f09a1 | 368 | foreach (explode("|", $value) as $val) { |
e5ccf3d9 | 369 | $val = str_replace('[:separator:]', '\|', $val); |
528f09a1 | 370 | $this->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fieldName, $op, $val, 'String'); |
371 | } | |
372 | } | |
373 | else { | |
e5ccf3d9 | 374 | $value = str_replace('[:separator:]', '\|', $value); |
528f09a1 | 375 | $this->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fieldName, $op, $value, 'String'); |
2c261619 | 376 | } |
6a488035 | 377 | } |
528f09a1 | 378 | else { |
379 | //FIX for custom data query fired against no value(NULL/NOT NULL) | |
380 | $this->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fieldName, $op, $value, 'String'); | |
381 | } | |
b4fb2d23 | 382 | $this->_qill[$grouping][] = $field['label'] . " $qillOp $qillValue"; |
6a488035 | 383 | } |
3130209f | 384 | break; |
6a488035 TO |
385 | |
386 | case 'ContactReference': | |
387 | $label = $value ? CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $value, 'sort_name') : ''; | |
388 | $this->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fieldName, $op, $value, 'String'); | |
2c261619 | 389 | $this->_qill[$grouping][] = $field['label'] . " $qillOp $label"; |
3130209f | 390 | break; |
6a488035 TO |
391 | |
392 | case 'Int': | |
4c2fe77b | 393 | $this->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fieldName, $op, $value, 'Integer'); |
394 | $this->_qill[$grouping][] = ts("%1 %2 %3", array(1 => $field['label'], 2 => $qillOp, 3 => $qillValue));; | |
3130209f | 395 | break; |
6a488035 TO |
396 | |
397 | case 'Boolean': | |
16b6d3d4 | 398 | if (!is_array($value)) { |
399 | if (strtolower($value) == 'yes' || strtolower($value) == strtolower(ts('Yes'))) { | |
400 | $value = 1; | |
401 | } | |
402 | else { | |
403 | $value = (int) $value; | |
404 | } | |
405 | $value = ($value == 1) ? 1 : 0; | |
406 | $qillValue = $value ? 'Yes' : 'No'; | |
6a488035 | 407 | } |
6a488035 | 408 | $this->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fieldName, $op, $value, 'Integer'); |
16b6d3d4 | 409 | $this->_qill[$grouping][] = ts("%1 %2 %3", array(1 => $field['label'], 2 => $qillOp, 3 => $qillValue)); |
3130209f | 410 | break; |
6a488035 TO |
411 | |
412 | case 'Link': | |
16b6d3d4 | 413 | case 'Memo': |
6a488035 | 414 | $this->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fieldName, $op, $value, 'String'); |
16b6d3d4 | 415 | $this->_qill[$grouping][] = ts("%1 %2 %3", array(1 => $field['label'], 2 => $qillOp, 3 => $qillValue)); |
3130209f | 416 | break; |
6a488035 TO |
417 | |
418 | case 'Money': | |
ec28b24d | 419 | $value = CRM_Utils_Array::value($op, (array) $value, $value); |
16b6d3d4 | 420 | if (is_array($value)) { |
6a488035 | 421 | foreach ($value as $key => $val) { |
ec28b24d | 422 | $value[$key] = CRM_Utils_Rule::cleanMoney($value[$key]); |
6a488035 | 423 | } |
16b6d3d4 | 424 | } |
425 | else { | |
426 | $value = CRM_Utils_Rule::cleanMoney($value); | |
427 | } | |
428 | ||
429 | case 'Float': | |
4c2fe77b | 430 | $this->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fieldName, $op, $value, 'Float'); |
431 | $this->_qill[$grouping][] = ts("%1 %2 %3", array(1 => $field['label'], 2 => $qillOp, 3 => $qillValue)); | |
3130209f | 432 | break; |
6a488035 | 433 | |
6a488035 | 434 | case 'Date': |
4c2fe77b | 435 | $this->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fieldName, $op, $value, 'String'); |
436 | list($qillOp, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue(NULL, $field['label'], $value, $op, array(), CRM_Utils_Type::T_DATE); | |
437 | $this->_qill[$grouping][] = "{$field['label']} $qillOp '$qillVal'"; | |
3130209f | 438 | break; |
6a488035 | 439 | |
6a488035 | 440 | case 'File': |
481a74f4 | 441 | if ($op == 'IS NULL' || $op == 'IS NOT NULL' || $op == 'IS EMPTY' || $op == 'IS NOT EMPTY') { |
6a488035 TO |
442 | switch ($op) { |
443 | case 'IS EMPTY': | |
444 | $op = 'IS NULL'; | |
445 | break; | |
2aa397bc | 446 | |
6a488035 TO |
447 | case 'IS NOT EMPTY': |
448 | $op = 'IS NOT NULL'; | |
449 | break; | |
450 | } | |
451 | $this->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fieldName, $op); | |
2c261619 | 452 | $this->_qill[$grouping][] = $field['label'] . " {$qillOp} "; |
6a488035 | 453 | } |
3130209f | 454 | break; |
6a488035 TO |
455 | } |
456 | } | |
457 | } | |
458 | } | |
459 | ||
460 | /** | |
d2e5d2ce | 461 | * Function that does the actual query generation. |
6a488035 TO |
462 | * basically ties all the above functions together |
463 | * | |
a6c01b45 CW |
464 | * @return array |
465 | * array of strings | |
6a488035 | 466 | */ |
00be9182 | 467 | public function query() { |
6a488035 TO |
468 | $this->select(); |
469 | ||
470 | $this->where(); | |
471 | ||
472 | $whereStr = NULL; | |
473 | if (!empty($this->_where)) { | |
474 | $clauses = array(); | |
475 | foreach ($this->_where as $grouping => $values) { | |
476 | if (!empty($values)) { | |
477 | $clauses[] = ' ( ' . implode(' AND ', $values) . ' ) '; | |
478 | } | |
479 | } | |
480 | if (!empty($clauses)) { | |
481 | $whereStr = ' ( ' . implode(' OR ', $clauses) . ' ) '; | |
482 | } | |
483 | } | |
484 | ||
353ffa53 TO |
485 | return array( |
486 | implode(' , ', $this->_select), | |
6a488035 TO |
487 | implode(' ', $this->_tables), |
488 | $whereStr, | |
489 | ); | |
490 | } | |
491 | ||
6a488035 | 492 | } |