public function searchLike($searchValues = array(), $searchFields = '*')
    {
        if (is_string($searchValues)) $searchValues = array('query' => $searchValues);
        if (is_string($searchFields)) $searchFields = array($searchFields);

        foreach ($searchValues as $column => $value) {
            if (empty($value) ||
                ($column != 'query' && !in_array($column, $this->_table()->getColumns()))
            ) {
                continue;
            }
            $searchWords = preg_split('/[\s-+,;*]/', $value);
            foreach ($searchWords as $searchWord) {
                $searchWord = trim($searchWord);
                if (empty($searchWord)) continue;

                if ($column == 'query') {
                    if (!$searchFields) {
                        throw new Kwf_Exception("Search field 'query' was found, "
                        ."but no 'searchFields' were given as second argument in "
                        ."'searchLike' method of Kwf_Db_Table_Select object");
                    }
                    if (in_array('*', $searchFields)) {
                        $searchFields = array_merge($searchFields, $this->_table()->getColumns());
                        foreach ($searchFields as $sfk => $sfv) {
                            if ($sfv == '*') unset($searchFields[$sfk]);
                            if (substr($sfv, 0, 1) == '!') {
                                unset($searchFields[$sfk]);
                                unset($searchFields[array_search(substr($sfv, 1), $searchFields)]);
                            }
                        }
                    }

                    $wheres = array();
                    foreach ($searchFields as $field) {
                        if (strpos($field, '.') === false) {
                            $field = $this->_table->getTableName().'.'.$field;
                        }
                        $wheres[] = Kwf_Registry::get('db')->quoteInto(
                            $field.' LIKE ?', "%$searchWord%"
                        );
                    }
                    $this->where(implode(' OR ', $wheres));
                } else {
                    $this->where($column.' LIKE ?', "%".$searchWord."%");
                }
            }
        }
        return $this;
    }
public function searchLike($searchValues = array(), $searchFields = '*')
    {
        if (is_string($searchValues)) $searchValues = array('query' => $searchValues);
        if (is_string($searchFields)) $searchFields = array($searchFields);

        foreach ($searchValues as $column => $value) {
            if (empty($value) ||
                ($column != 'query' && !in_array($column, $this->_table()->getColumns()))
            ) {
                continue;
            }
            $searchWords = preg_split('/[\s-+,;*]/', $value);
            foreach ($searchWords as $searchWord) {
                $searchWord = trim($searchWord);
                if (empty($searchWord)) continue;

                if ($column == 'query') {
                    if (!$searchFields) {
                        throw new Kwf_Exception("Search field 'query' was found, "
                        ."but no 'searchFields' were given as second argument in "
                        ."'searchLike' method of Kwf_Db_Table_Select object");
                    }
                    if (in_array('*', $searchFields)) {
                        $searchFields = array_merge($searchFields, $this->_table()->getColumns());
                        foreach ($searchFields as $sfk => $sfv) {
                            if ($sfv == '*') unset($searchFields[$sfk]);
                            if (substr($sfv, 0, 1) == '!') {
                                unset($searchFields[$sfk]);
                                unset($searchFields[array_search(substr($sfv, 1), $searchFields)]);
                            }
                        }
                    }

                    $wheres = array();
                    foreach ($searchFields as $field) {
                        if (strpos($field, '.') === false) {
                            $field = $this->_table->getTableName().'.'.$field;
                        }
                        $wheres[] = Kwf_Registry::get('db')->quoteInto(
                            $field.' LIKE ?', "%$searchWord%"
                        );
                    }
                    $this->where(implode(' OR ', $wheres));
                } else {
                    $this->where($column.' LIKE ?', "%".$searchWord."%");
                }
            }
        }
        return $this;
    }
public function searchLike ( $ searchValues = array ( ) , $ searchFields = '*' ) { if ( is_string ( $ searchValues ) ) $ searchValues = array ( 'query' => $ searchValues ) ; if ( is_string ( $ searchFields ) ) $ searchFields = array ( $ searchFields ) ; foreach ( $ searchValues as $ column => $ value ) { if ( empty ( $ value ) || ( $ column != 'query' && ! in_array ( $ column , $ this -> _table ( ) -> getColumns ( ) ) ) ) { continue ; } $ searchWords = preg_split ( '/[\s-+,;*]/' , $ value ) ; foreach ( $ searchWords as $ searchWord ) { $ searchWord = trim ( $ searchWord ) ; if ( empty ( $ searchWord ) ) continue ; if ( $ column == 'query' ) { if ( ! $ searchFields ) { throw new Kwf_Exception ( "Search field 'query' was found, " . "but no 'searchFields' were given as second argument in " . "'searchLike' method of Kwf_Db_Table_Select object" ) ; } if ( in_array ( '*' , $ searchFields ) ) { $ searchFields = array_merge ( $ searchFields , $ this -> _table ( ) -> getColumns ( ) ) ; foreach ( $ searchFields as $ sfk => $ sfv ) { if ( $ sfv == '*' ) unset ( $ searchFields [ $ sfk ] ) ; if ( substr ( $ sfv , 0 , 1 ) == '!' ) { unset ( $ searchFields [ $ sfk ] ) ; unset ( $ searchFields [ array_search ( substr ( $ sfv , 1 ) , $ searchFields ) ] ) ; } } } $ wheres = array ( ) ; foreach ( $ searchFields as $ field ) { if ( strpos ( $ field , '.' ) === false ) { $ field = $ this -> _table -> getTableName ( ) . '.' . $ field ; } $ wheres [ ] = Kwf_Registry :: get ( 'db' ) -> quoteInto ( $ field . ' LIKE ?' , "%$searchWord%" ) ; } $ this -> where ( implode ( ' OR ' , $ wheres ) ) ; } else { $ this -> where ( $ column . ' LIKE ?' , "%" . $ searchWord . "%" ) ; } } } return $ this ; }
Adds the needed wheres for a search

@deprecated use Kwf_Model_Select_Expr_SearchLike instead
@param string|array $searchValues An array with the db-field in the key
and the search value as value. Field query means to search in all given fields
for this value (see the second argument). If a string is given, it is interpreted
like array('query' => $searchValues).
@param string|array $searchFields The fields that should be searched with
search field 'query'. If a string is given, it is treated like array($string).
Value '*' means to search in all fields in the table.
@return object $this The select object itself
Adds the needed wheres for a search