"fix for bug #2025: Database error in Timesheet with selected view category/date"

This commit is contained in:
Ralf Becker 2009-04-01 20:01:54 +00:00
parent 1092f3213e
commit b7444a9598

View File

@ -379,6 +379,10 @@ class so_sql_cf extends so_sql
*/
function &search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter=null,$join='',$need_full_no_count=false)
{
if ($only_keys === false)
{
$only_keys = $this->table_name.'.*';
}
// check if we search in the custom fields
if ($criteria && is_array($criteria) && isset($criteria[$this->extra_value]))
{
@ -407,9 +411,20 @@ class so_sql_cf extends so_sql
}
// check if we filter by a custom field
if (is_array($filter))
{
foreach($filter as $name => $val)
{
if (is_string($name) && $name[0] == self::CF_PREFIX)
// replace ambiguous auto-id with (an exact match of) table_name.autoid
if ($name == $this->autoinc_id)
{
if ((int)$filter[$this->autoinc_id])
{
$filter[] = $this->table_name.'.'.$this->autoinc_id.'='.(int)$filter[$this->autoinc_id];
}
unset($filter[$this->autoinc_id]);
}
elseif (is_string($name) && $name[0] == self::CF_PREFIX)
{
if (!empty($val)) // empty -> dont filter
{
@ -430,7 +445,7 @@ class so_sql_cf extends so_sql
unset($filter[$name]);
}
}
}
return parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,$start,$filter,$join,$need_full_no_count);
}