/** * Apply filters to the queryscheme * * @param One_Query $q */ public function affect(One_Query $query) { $cx = new One_Context(); $term = $cx->get('term', ''); $field = $cx->get('field', $query->getScheme()->getIdentityAttribute()->getName()); if ('' != trim($term)) { $query->where($field, 'contains', $term); } else { $query->where('isFalse', 'literal', 'false'); } }
public function affect(One_Query $query) { $search = $this->_filterParams['search']; if ($search) { $query->where('name', 'like', "%{$search}%"); } }
/** * Affect the One_Query appropriately * * @param One_Query $q * @param string $attrName * @param mixed $attrVal * @final */ public final function affectQuery(One_Query $q, $attrName, $attrVal) { $allowed = self::getAllowed(); $opVal = $this->getValue(); if (!is_null($opVal)) { if (in_array($opVal, $allowed)) { $op = $opVal; } else { $op = $allowed['default']; } } $q->where($attrName, $op, $attrVal); }
/** * Apply filters to the queryscheme * * @param One_Query $q */ public function affect(One_Query $query) { $filters = array(); $unparsed_filters = $this->filters(); foreach ($unparsed_filters as $key => $value) { $tmp = explode("__", $key); switch ($tmp[1]) { case "op": case "value": $filters[$tmp[0]][$tmp[1]] = $value; break; default: throw new One_Exception('Expecting params in the form attribute__op or attribute__value'); break; } } foreach ($filters as $attribute => $options) { if (trim($options['op']) != '' && trim($options['value']) != '') { $query->where($attribute, $options['op'], $options['value']); } else { throw new One_Exception('Expecting both an operator and a value for attribute ' . $attribute); } } }
public function affect(One_Query $query) { $query->where('enabled', 'eq', 1); }