diff --git a/addressbook/inc/class.contacts_sql.inc.php b/addressbook/inc/class.contacts_sql.inc.php index b7c7ed84b0..2fc199630f 100644 --- a/addressbook/inc/class.contacts_sql.inc.php +++ b/addressbook/inc/class.contacts_sql.inc.php @@ -313,7 +313,7 @@ global $phpgw,$phpgw_info; if (!$fields || empty($fields)) { $fields = $this->stock_contact_fields; } - $DEBUG = 0; + $DEBUG = 1; list($stock_fields,$stock_fieldnames,$extra_fields) = $this->split_stock_and_extras($fields); if (count($stock_fieldnames)) @@ -390,13 +390,18 @@ { if ($fvalue==$name) { - if (gettype($value) == "integer") + if ($name == 'cat_id') { - $filterlist .= $name."=".$value.","; + // This is the alternative to CONCAT, since it is mysql-only + $filterlist .= "(" . $name . " LIKE '%," . $value . ",%' OR " . $name."=".$value.");"; + } + elseif (gettype($value) == "integer") + { + $filterlist .= $name."=".$value.";"; } else { - $filterlist .= $name."='".$value."',"; + $filterlist .= $name."='".$value."';"; } break; } @@ -405,11 +410,12 @@ $i++; } $filterlist = substr($filterlist,0,-1); - $filterlist = ereg_replace(","," AND ",$filterlist); + $filterlist = ereg_replace(";"," AND ",$filterlist); // echo "
contacts->read(): filterlist=\"$filterlist\" -->"; // allow multiple (','-separated) cat's per address - $filterlist = ereg_replace('cat_id=[\']*([0-9]+)[\']*',"CONCAT(',',cat_id,',') LIKE '%,\\1,%'",$filterlist); + //$filterlist = ereg_replace('cat_id=[\']*([0-9]+)[\']*',"CONCAT(',',cat_id,',') LIKE '%,\\1,%'",$filterlist); // echo "\"$filterlist\"
\n"; + // Oops, CONCAT is mysql-only, this is now handled explicitly above for cat_id if ($DEBUG) { @@ -535,6 +541,8 @@ . $filtermethod . " " . $ordermethod . " " . $limit,__LINE__,__FILE__); } + if ($DEBUG) { echo "