}
$where[0] = 'FALSE ';
foreach($search_fields[$class] as $column) $where[0] .= "OR $column REGEXP $search ";
} elseif($id) $where[1] = "$class$suffix_id = $id";
if(!$history && $this->contains_history($class)) $where[2] = $class.'_valid_till=0';
if($where) $sql .= 'WHERE '.implode(' AND ', $where)."\n";
}
$where[0] = 'FALSE ';
foreach($search_fields[$class] as $column) $where[0] .= "OR $column REGEXP $search ";
} elseif($id) $where[1] = "$class$suffix_id = $id";
if(!$history && $this->contains_history($class)) $where[2] = $class.'_valid_till=0';
if($where) $sql .= 'WHERE '.implode(' AND ', $where)."\n";