public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation = false) { // X to Y support if (preg_match('/^(-?(?:\\d+(?:\\.\\d+)?|\\.\\d+)) to (-?(?:\\d+(?:\\.\\d+)?|\\.\\d+))$/i', $data[0], $match)) { $field_id = $this->get('id'); $joins .= " LEFT JOIN `tbl_entries_data_{$field_id}` AS `t{$field_id}` ON (`e`.`id` = `t{$field_id}`.entry_id) "; $where .= " AND `t{$field_id}`.`value` BETWEEN {$match[1]} AND {$match[2]} "; } else { if (preg_match('/^(equal to or )?(less|greater) than (-?(?:\\d+(?:\\.\\d+)?|\\.\\d+))$/i', $data[0], $match)) { $field_id = $this->get('id'); $expression = " `t{$field_id}`.`value` "; switch ($match[2]) { case 'less': $expression .= '<'; break; case 'greater': $expression .= '>'; break; } if ($match[1]) { $expression .= '='; } $expression .= " {$match[3]} "; $joins .= " LEFT JOIN `tbl_entries_data_{$field_id}` AS `t{$field_id}` ON (`e`.`id` = `t{$field_id}`.entry_id) "; $where .= " AND {$expression} "; } else { parent::buildDSRetrievalSQL($data, $joins, $where, $andOperation); } } return true; }
function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation = false) { // Check its not a regexp if (preg_match('/^mysql:/i', $data[0])) { $field_id = $this->get('id'); $expression = str_replace(array('mysql:', 'value'), array('', " `t{$field_id}`.`value` "), $data[0]); $joins .= " LEFT JOIN `tbl_entries_data_{$field_id}` AS `t{$field_id}` ON (`e`.`id` = `t{$field_id}`.entry_id) "; $where .= " AND {$expression} "; } else { parent::buildDSRetrievalSQL($data, $joins, $where, $andOperation); } return true; }
public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation = false) { if (self::isFilterRegex($data[0])) { return parent::buildDSRetrievalSQL($data, $joins, $where, $andOperation); } $parsed = array(); foreach ($data as $string) { $type = self::parseFilter($string); if ($type == self::ERROR) { return false; } if (!is_array($parsed[$type])) { $parsed[$type] = array(); } $parsed[$type][] = $string; } foreach ($parsed as $type => $value) { switch ($type) { case self::RANGE: $this->buildRangeFilterSQL($value, $joins, $where, $andOperation); break; case self::SIMPLE: $this->buildSimpleFilterSQL($value, $joins, $where, $andOperation); break; } } return true; }
public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation = false) { if (self::isFilterRegex($data[0])) { return parent::buildDSRetrievalSQL($data, $joins, $where, $andOperation); } $parsed = array(); // For the filter provided, loop over each piece foreach ($data as $string) { $type = self::parseFilter($string); if ($type == self::ERROR) { return false; } if (!is_array($parsed[$type])) { $parsed[$type] = array(); } $parsed[$type][] = $string; } foreach ($parsed as $value) { $this->buildRangeFilterSQL($value, $joins, $where, $andOperation); } return true; }