Changeset 1637 in subversion


Ignore:
Timestamp:
Aug 9, 2008 4:20:59 PM (5 years ago)
Author:
alec
Message:
  • Case insensitive contacts searching using PostgreSQL (#1485259)
Location:
trunk/roundcubemail
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/CHANGELOG

    r1623 r1637  
    11CHANGELOG RoundCube Webmail 
    22--------------------------- 
     3 
     42008/08/09 (alec) 
     5---------- 
     6- Case insensitive contacts searching using PostgreSQL (#1485259) 
    37 
    482008/07/31 (thomasb) 
  • trunk/roundcubemail/program/include/rcube_contacts.php

    r1387 r1637  
    197197      { 
    198198        $ids = !is_array($value) ? split(',', $value) : $value; 
    199         $add_where[] = $this->primary_key." IN (".join(',', $ids).")"; 
     199        $add_where[] = $this->primary_key.' IN ('.join(',', $ids).')'; 
    200200      } 
    201201      else if ($strict) 
    202         $add_where[] = $this->db->quoteIdentifier($col)."=".$this->db->quote($value); 
     202        $add_where[] = $this->db->quoteIdentifier($col).'='.$this->db->quote($value); 
    203203      else 
    204         $add_where[] = $this->db->quoteIdentifier($col)." LIKE ".$this->db->quote(strlen($value)>2 ? "%$value%" : "$value%"); 
     204        $add_where[] = $this->db->ilike($col, '%'.$value.'%'); 
    205205    } 
    206206     
  • trunk/roundcubemail/program/include/rcube_db.php

    r1291 r1637  
    512512 
    513513  /** 
     514   * Return SQL statement for case insensitive LIKE 
     515   * 
     516   * @param  string  Field name 
     517   * @param  string  Search value 
     518   * @return string  SQL statement to use in query 
     519   * @access public 
     520   */ 
     521  function ilike($column, $value) 
     522    { 
     523    switch($this->db_provider) 
     524      { 
     525      case 'pgsql': 
     526        return $this->quote_identifier($column).' ILIKE '.$this->quote($value); 
     527      default: 
     528        return $this->quote_identifier($column).' LIKE '.$this->quote($value); 
     529      } 
     530    } 
     531 
     532 
     533  /** 
    514534   * Adds a query result and returns a handle ID 
    515535   * 
  • trunk/roundcubemail/program/include/rcube_mdb2.php

    r1631 r1637  
    510510 
    511511  /** 
     512   * Return SQL statement for case insensitive LIKE 
     513   * 
     514   * @param  string  Field name 
     515   * @param  string  Search value 
     516   * @return string  SQL statement to use in query 
     517   * @access public 
     518   */ 
     519  function ilike($column, $value) 
     520    { 
     521    // TODO: use MDB2's matchPattern() function 
     522    switch($this->db_provider) 
     523      { 
     524      case 'pgsql': 
     525        return $this->quote_identifier($column).' ILIKE '.$this->quote($value); 
     526      default: 
     527        return $this->quote_identifier($column).' LIKE '.$this->quote($value); 
     528      } 
     529    } 
     530 
     531 
     532  /** 
    512533   * Adds a query result and returns a handle ID 
    513534   * 
Note: See TracChangeset for help on using the changeset viewer.