Lo mejor es armar dinámicamente el query:
Código PHP:
Ver original$query = 'SELECT * FROM foo';
if (foo()) {
$conditions[] = "foo = 'foo'";
}
if (bar()) {
$conditions[] = "bar= 'bar'";
}
if (baz()) {
$conditions[] = "baz= 'baz'";
}
if (count($conditions) > 0)) { $query .= ' WHERE ' . implode(' AND ', $conditions); }
Saludos.