From 3993c41752ea7e6833d8bf6c3989fd8a6e96ebd3 Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Fri, 23 Nov 2001 00:59:02 +0000 Subject: [PATCH] Make query into a loop to check all std fields. --- phpgwapi/inc/class.contacts_sql.inc.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/phpgwapi/inc/class.contacts_sql.inc.php b/phpgwapi/inc/class.contacts_sql.inc.php index cf7ac5c9e8..887d4a4ee8 100644 --- a/phpgwapi/inc/class.contacts_sql.inc.php +++ b/phpgwapi/inc/class.contacts_sql.inc.php @@ -472,20 +472,24 @@ if ($query) { - $sql = "SELECT * FROM $this->std_table WHERE (bday LIKE '%$query%' OR n_family LIKE '" - . "%$query%' OR n_given LIKE '%$query%' OR email LIKE '%$query%' OR " - . "adr_one_street LIKE '%$query%' OR adr_one_locality LIKE '%$query%' OR adr_one_region LIKE '%$query%' OR " - . "adr_one_postalcode LIKE '%$query%' OR adr_one_countryname LIKE '%$query%' OR " - . "adr_two_street LIKE '%$query%' OR adr_two_locality LIKE '%$query%' OR adr_two_region LIKE '%$query%' OR " - . "adr_two_postalcode LIKE '%$query%' OR adr_two_countryname LIKE '%$query%' OR " - . "org_name LIKE '%$query%' OR org_unit LIKE '%$query%') " . $fand . $filtermethod . $ordermethod; + $query = ereg_replace("'",'',$query); + $query = ereg_replace('"','',$query); + + $sql = "SELECT * FROM $this->std_table WHERE ("; + reset($this->stock_contact_fields); + while(list($f,$x) = each($this->stock_contact_fields)) + { + $sql .= " $f LIKE '%$query%' OR "; + } + $sql = substr($sql,0,-3) . ') ' . $fand . $filtermethod . $ordermethod; + unset($f); unset($x); } else { $sql = "SELECT id,lid,tid,owner,access,cat_id $t_fields FROM $this->std_table " . $fwhere . $filtermethod . ' ' . $ordermethod; } - if ($DEBUG) { echo "
$sql"; } + if ($DEBUG) { echo '
' . $sql; } $db2 = $this->db;