/** * This implementation allows for a list of columns to be passed into MATCH() instead of just one. * * @example * <code> * MyDataObject::get()->filter('SearchFields:fulltext', 'search term') * </code> * * @throws Exception * @return string */ public function getDbName() { $indexes = Config::inst()->get($this->model, "indexes"); if (is_array($indexes) && array_key_exists($this->getName(), $indexes)) { $index = $indexes[$this->getName()]; if (is_array($index) && array_key_exists("value", $index)) { return $this->prepareColumns($index['value']); } else { // Parse a fulltext string (eg. fulltext ("ColumnA", "ColumnB")) to figure out which columns // we need to search. if (preg_match('/^fulltext\\s+\\((.+)\\)$/i', $index, $matches)) { return $this->prepareColumns($matches[1]); } else { throw new Exception(sprintf("Invalid fulltext index format for '%s' on '%s'", $this->getName(), $this->model)); } } } return parent::getDbName(); }
/** * Adds a instance of {@link SearchFilter}. * * @param SearchFilter $filter */ public function addFilter($filter) { $this->filters[$filter->getFullName()] = $filter; }