roundcubemail/program/lib/Roundcube/rcube_contacts.php
private function fulltext_sql_where($value, $mode, $col = 'words', $bool = 'AND')
    {
        $WS = ' ';
        $AS = $col == 'words' ? $WS : self::SEPARATOR;
        $words = $col == 'words' ? rcube_utils::normalize_string($value, true) : array($value);

        $where = array();
        foreach ($words as $word) {
            if ($mode & rcube_addressbook::SEARCH_STRICT) {
                $where[] = '(' . $this->db->ilike($col, $word)
                    . ' OR ' . $this->db->ilike($col, $word . $AS . '%')
                    . ' OR ' . $this->db->ilike($col, '%' . $AS . $word . $AS . '%')
                    . ' OR ' . $this->db->ilike($col, '%' . $AS . $word) . ')';
            }
            else if ($mode & rcube_addressbook::SEARCH_PREFIX) {
                $where[] = '(' . $this->db->ilike($col, $word . '%')
                    . ' OR ' . $this->db->ilike($col, '%' . $AS . $word . '%') . ')';
            }
            else {
                $where[] = $this->db->ilike($col, '%' . $word . '%');
            }
        }

        return count($where) ? '(' . join(" $bool ", $where) . ')' : '';
    }
private function fulltext_sql_where($value, $mode, $col = 'words', $bool = 'AND')
    {
        $WS = ' ';
        $AS = $col == 'words' ? $WS : self::SEPARATOR;
        $words = $col == 'words' ? rcube_utils::normalize_string($value, true) : array($value);

        $where = array();
        foreach ($words as $word) {
            if ($mode & rcube_addressbook::SEARCH_STRICT) {
                $where[] = '(' . $this->db->ilike($col, $word)
                    . ' OR ' . $this->db->ilike($col, $word . $AS . '%')
                    . ' OR ' . $this->db->ilike($col, '%' . $AS . $word . $AS . '%')
                    . ' OR ' . $this->db->ilike($col, '%' . $AS . $word) . ')';
            }
            else if ($mode & rcube_addressbook::SEARCH_PREFIX) {
                $where[] = '(' . $this->db->ilike($col, $word . '%')
                    . ' OR ' . $this->db->ilike($col, '%' . $AS . $word . '%') . ')';
            }
            else {
                $where[] = $this->db->ilike($col, '%' . $word . '%');
            }
        }

        return count($where) ? '(' . join(" $bool ", $where) . ')' : '';
    }
private function fulltext_sql_where ( $ value , $ mode , $ col = 'words' , $ bool = 'AND' ) { $ WS = ' ' ; $ AS = $ col == 'words' ? $ WS : self :: SEPARATOR ; $ words = $ col == 'words' ? rcube_utils :: normalize_string ( $ value , true ) : array ( $ value ) ; $ where = array ( ) ; foreach ( $ words as $ word ) { if ( $ mode & rcube_addressbook :: SEARCH_STRICT ) { $ where [ ] = '(' . $ this -> db -> ilike ( $ col , $ word ) . ' OR ' . $ this -> db -> ilike ( $ col , $ word . $ AS . '%' ) . ' OR ' . $ this -> db -> ilike ( $ col , '%' . $ AS . $ word . $ AS . '%' ) . ' OR ' . $ this -> db -> ilike ( $ col , '%' . $ AS . $ word ) . ')' ; } else if ( $ mode & rcube_addressbook :: SEARCH_PREFIX ) { $ where [ ] = '(' . $ this -> db -> ilike ( $ col , $ word . '%' ) . ' OR ' . $ this -> db -> ilike ( $ col , '%' . $ AS . $ word . '%' ) . ')' ; } else { $ where [ ] = $ this -> db -> ilike ( $ col , '%' . $ word . '%' ) ; } } return count ( $ where ) ? '(' . join ( " $bool " , $ where ) . ')' : '' ; }
Helper method to compose SQL where statements for fulltext searching
Helper method to compose SQL where statements for fulltext searching