| @@ 617-664 (lines=48) @@ | ||
| 614 | } |
|
| 615 | } |
|
| 616 | ||
| 617 | public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation = false) |
|
| 618 | { |
|
| 619 | $field_id = $this->get('id'); |
|
| 620 | ||
| 621 | if (self::isFilterRegex($data[0])) { |
|
| 622 | $this->buildRegexSQL($data[0], array('value', 'handle'), $joins, $where); |
|
| 623 | } elseif ($andOperation) { |
|
| 624 | foreach ($data as $value) { |
|
| 625 | $this->_key++; |
|
| 626 | $value = $this->cleanValue($value); |
|
| 627 | $joins .= " |
|
| 628 | LEFT JOIN |
|
| 629 | `tbl_entries_data_{$field_id}` AS t{$field_id}_{$this->_key} |
|
| 630 | ON (e.id = t{$field_id}_{$this->_key}.entry_id) |
|
| 631 | "; |
|
| 632 | $where .= " |
|
| 633 | AND ( |
|
| 634 | t{$field_id}_{$this->_key}.value = '{$value}' |
|
| 635 | OR t{$field_id}_{$this->_key}.handle = '{$value}' |
|
| 636 | ) |
|
| 637 | "; |
|
| 638 | } |
|
| 639 | } else { |
|
| 640 | if (!is_array($data)) { |
|
| 641 | $data = array($data); |
|
| 642 | } |
|
| 643 | ||
| 644 | foreach ($data as &$value) { |
|
| 645 | $value = $this->cleanValue($value); |
|
| 646 | } |
|
| 647 | ||
| 648 | $this->_key++; |
|
| 649 | $data = implode("', '", $data); |
|
| 650 | $joins .= " |
|
| 651 | LEFT JOIN |
|
| 652 | `tbl_entries_data_{$field_id}` AS t{$field_id}_{$this->_key} |
|
| 653 | ON (e.id = t{$field_id}_{$this->_key}.entry_id) |
|
| 654 | "; |
|
| 655 | $where .= " |
|
| 656 | AND ( |
|
| 657 | t{$field_id}_{$this->_key}.value IN ('{$data}') |
|
| 658 | OR t{$field_id}_{$this->_key}.handle IN ('{$data}') |
|
| 659 | ) |
|
| 660 | "; |
|
| 661 | } |
|
| 662 | ||
| 663 | return true; |
|
| 664 | } |
|
| 665 | } |
|
| 666 | ||
| @@ 294-341 (lines=48) @@ | ||
| 291 | Filtering: |
|
| 292 | -------------------------------------------------------------------------*/ |
|
| 293 | ||
| 294 | public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation = false) |
|
| 295 | { |
|
| 296 | $field_id = $this->get('id'); |
|
| 297 | ||
| 298 | if (self::isFilterRegex($data[0])) { |
|
| 299 | $this->buildRegexSQL($data[0], array('value', 'handle'), $joins, $where); |
|
| 300 | } elseif ($andOperation) { |
|
| 301 | foreach ($data as $value) { |
|
| 302 | $this->_key++; |
|
| 303 | $value = $this->cleanValue($value); |
|
| 304 | $joins .= " |
|
| 305 | LEFT JOIN |
|
| 306 | `tbl_entries_data_{$field_id}` AS t{$field_id}_{$this->_key} |
|
| 307 | ON (e.id = t{$field_id}_{$this->_key}.entry_id) |
|
| 308 | "; |
|
| 309 | $where .= " |
|
| 310 | AND ( |
|
| 311 | t{$field_id}_{$this->_key}.value = '{$value}' |
|
| 312 | OR t{$field_id}_{$this->_key}.handle = '{$value}' |
|
| 313 | ) |
|
| 314 | "; |
|
| 315 | } |
|
| 316 | } else { |
|
| 317 | if (!is_array($data)) { |
|
| 318 | $data = array($data); |
|
| 319 | } |
|
| 320 | ||
| 321 | foreach ($data as &$value) { |
|
| 322 | $value = $this->cleanValue($value); |
|
| 323 | } |
|
| 324 | ||
| 325 | $this->_key++; |
|
| 326 | $data = implode("', '", $data); |
|
| 327 | $joins .= " |
|
| 328 | LEFT JOIN |
|
| 329 | `tbl_entries_data_{$field_id}` AS t{$field_id}_{$this->_key} |
|
| 330 | ON (e.id = t{$field_id}_{$this->_key}.entry_id) |
|
| 331 | "; |
|
| 332 | $where .= " |
|
| 333 | AND ( |
|
| 334 | t{$field_id}_{$this->_key}.value IN ('{$data}') |
|
| 335 | OR t{$field_id}_{$this->_key}.handle IN ('{$data}') |
|
| 336 | ) |
|
| 337 | "; |
|
| 338 | } |
|
| 339 | ||
| 340 | return true; |
|
| 341 | } |
|
| 342 | ||
| 343 | /*------------------------------------------------------------------------- |
|
| 344 | Sorting: |
|