From 33918385fc82cb8da75db2995ea19a2c78a68cb8 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sun, 19 Sep 2004 12:34:34 +0000 Subject: [PATCH] fixed 2 other probs: - cat_id is varchar, so the id's in "cat_id IN ('1','2')" have to be in single quotes for MaxDB - search on text-columns: * MsSQL need to cast the column to varchar * MaxDB cant do it at all --- phpgwapi/inc/class.contacts_sql.inc.php | 30 ++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/phpgwapi/inc/class.contacts_sql.inc.php b/phpgwapi/inc/class.contacts_sql.inc.php index e0cc420570..922032b19f 100644 --- a/phpgwapi/inc/class.contacts_sql.inc.php +++ b/phpgwapi/inc/class.contacts_sql.inc.php @@ -300,7 +300,7 @@ $GLOBALS['phpgw']->categories = CreateObject('phpgwapi.categories'); } $cats = $GLOBALS['phpgw']->categories->return_all_children((int)$value); - $cat_filter = '(cat_id IN ('.implode(',',$cats).')'; + $cat_filter = "(cat_id IN ('".implode("','",$cats)."')"; foreach($cats as $cat) { $cat_filter .= " OR cat_id LIKE '%,$cat,%'"; @@ -445,6 +445,20 @@ { continue; // this can be something nasty } + // special handling of text columns for certain db's; + if (in_array($f,array('note','pubkey','label'))) + { + switch($this->db->Type) + { + case 'sapdb': case 'maxdb': + $queryKey = false; // sapdb cant use LIKE on text/LONG columns + break; + case 'mssql': + $queryKey = "CAST($queryKey AS varchar)"; // mssql cant use UPPER on text columns + break; + } + if (!$queryKey) continue; + } $queryValue = strtoupper($this->db->db_addslashes($queryValue)); $sql .= " UPPER($queryKey) LIKE '$queryValue' AND "; $sqlcount .= " UPPER($queryKey) LIKE '$queryValue' AND "; @@ -461,6 +475,20 @@ $sqlcount = "SELECT COUNT(*) FROM $this->std_table WHERE ("; foreach($this->stock_contact_fields as $f => $x) { + // special handling of text columns for certain db's; + if (in_array($f,array('note','pubkey','label'))) + { + switch($this->db->Type) + { + case 'sapdb': case 'maxdb': + $f = false; // sapdb cant use LIKE on text/LONG columns + break; + case 'mssql': + $f = "CAST($f AS varchar)"; // mssql cant use UPPER on text columns + break; + } + if (!$f) continue; + } $sql .= " UPPER($f) LIKE '%$query%' OR "; $sqlcount .= " UPPER($f) LIKE '%$query%' OR "; }