/** * * @param string $filter The text to filter for * @param string $name The model field name * @param string $sqlField The SQL field name * @param \MUtil_Model_DatabaseModelAbstract $model * @return array Array of OR-filter statements */ public function textFilter($filter, $name, $sqlField, \MUtil_Model_DatabaseModelAbstract $model) { $options = $model->get($name, 'multiOptions'); if ($options) { $adapter = $model->getAdapter(); $wheres = array(); foreach ($options as $key => $value) { // \MUtil_Echo::track($key, $value, $filter, stripos($value, $filter)); if (stripos($value, $filter) === false) { continue; } if (null === $key) { $wheres[] = $sqlField . ' IS NULL'; } else { $wheres[] = $adapter->quoteInto($sqlField . " LIKE ?", '%' . $this->seperatorChar . $key . $this->seperatorChar . '%'); if (!$this->valuePad) { // Add other options $wheres[] = $adapter->quoteInto($sqlField . " LIKE ?", $key . $this->seperatorChar . '%'); $wheres[] = $adapter->quoteInto($sqlField . " LIKE ?", '%' . $this->seperatorChar . $key); $wheres[] = $adapter->quoteInto($sqlField . " = ?", $key); } } } return $wheres; } }