From f4238614f3ef29cc2aac1609cce95fe1b40a8359 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sun, 17 Dec 2006 08:44:05 +0000 Subject: [PATCH] new egw_db::capabilities['case_insensitive_like']=='LIKE' ('ILIKE' for Postgres) used for all so_sql search and the lettersearch in addressbook --- addressbook/inc/class.uicontacts.inc.php | 4 ++-- etemplate/inc/class.so_sql.inc.php | 4 ++-- phpgwapi/inc/class.egw_db.inc.php | 14 ++++++++------ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/addressbook/inc/class.uicontacts.inc.php b/addressbook/inc/class.uicontacts.inc.php index 75995f5aa5..43f45dd0cf 100644 --- a/addressbook/inc/class.uicontacts.inc.php +++ b/addressbook/inc/class.uicontacts.inc.php @@ -628,8 +628,8 @@ class uicontacts extends bocontacts } if ($query['searchletter']) // only show contacts if the order-criteria starts with the given letter { - $query['col_filter'][] = ($query['order']=='adr_one_postalcode' ? 'org_name' : $query['order']). - ' LIKE '.$GLOBALS['egw']->db->quote($query['searchletter'].'%'); + $query['col_filter'][] = ($query['order'] == 'adr_one_postalcode' ? 'org_name' : $query['order']).' '. + $GLOBALS['egw']->db->capabilities['case_insensitive_like'].' '.$GLOBALS['egw']->db->quote($query['searchletter'].'%'); } $wildcard = '%'; $op = 'OR'; diff --git a/etemplate/inc/class.so_sql.inc.php b/etemplate/inc/class.so_sql.inc.php index b5dfd99a40..cbe0f1c069 100644 --- a/etemplate/inc/class.so_sql.inc.php +++ b/etemplate/inc/class.so_sql.inc.php @@ -517,10 +517,10 @@ class so_sql if ($wildcard || $criteria[$col]{0} == '!' || is_string($criteria[$col]) && (strpos($criteria[$col],'*')!==false || strpos($criteria[$col],'?')!==false)) { - $cmp_op = ' LIKE '; + $cmp_op = ' '.$this->db->capabilities['case_insensitive_like'].' '; if ($criteria[$col]{0} == '!') { - $cmp_op = ' NOT LIKE '; + $cmp_op = ' NOT'.$cmp_op; $criteria[$col] = substr($criteria[$col],1); } $query[] = $db_col.$cmp_op.$this->db->quote($wildcard.str_replace(array('%','_','*','?'),array('\\%','\\_','%','_'),$criteria[$col]).$wildcard); diff --git a/phpgwapi/inc/class.egw_db.inc.php b/phpgwapi/inc/class.egw_db.inc.php index 2788647289..3628a44ad6 100644 --- a/phpgwapi/inc/class.egw_db.inc.php +++ b/phpgwapi/inc/class.egw_db.inc.php @@ -119,15 +119,16 @@ * @var array $capabilities, defaults will be changed be method set_capabilities($ado_driver,$db_version) */ var $capabilities = array( - 'sub_queries' => true, // will be set to false for mysql < 4.1 - 'union' => true, // will be set to false for mysql < 4.0 + 'sub_queries' => true, // will be set to false for mysql < 4.1 + 'union' => true, // will be set to false for mysql < 4.0 'outer_join' => false, // does the DB has an outer join, will be set eg. for postgres - 'distinct_on_text' => true, // is the DB able to use DISTINCT with a text or blob column - 'like_on_text' => true, // is the DB able to use LIKE with text columns + 'distinct_on_text' => true, // is the DB able to use DISTINCT with a text or blob column + 'like_on_text' => true, // is the DB able to use LIKE with text columns 'name_case' => 'upper', // case of returned column- and table-names: upper, lower(pgSql), preserv(MySQL) 'client_encoding' => false, // db uses a changeable clientencoding - 'order_on_text' => true, // is the DB able to order by a given text column, boolean or - ); // string for sprintf for a cast (eg. 'CAST(%s AS varchar)') + 'case_insensitive_like' => 'LIKE', // case insensitive version of like, eg. ILIKE for postgres + 'order_on_text' => true, // is the DB able to order by a given text column, boolean or + ); // string for sprintf for a cast (eg. 'CAST(%s AS varchar)') var $prepared_sql = array(); // sql is the index @@ -341,6 +342,7 @@ $this->capabilities['name_case'] = 'lower'; $this->capabilities['client_encoding'] = (float) $db_version >= 7.4; $this->capabilities['outer_join'] = true; + $this->capabilities['case_insensitive_like'] = 'ILIKE'; break; case 'mssql':