I am working on an Symfony 1.4 project and need to customize a backend filter "name", so that the column "name_full" is searched simultaneously with the "name" column.
I thought of doing it like that in my FormFilterClass:
public function addNameColumnQuery(Doctrine_Query $query, $field, $value) {
$rootAlias = $query->getRootAlias();
return $query->where(''.$rootAlias.'.name LIKE ?', "%$value%")
->orWhere(''.$rootAlias.'.name_full LIKE ?', "%$value%");
}
but that doesn't work as it gives me a wrong result set. And I fail to find the file where I could dump the complete dql for debugging.
Please point out where I could dump the complete dql or even tell me what is wrong with my approach.
Thank you!
EDIT: This is the correct function as suggested by Michal and tweaked by me:
public function addNameColumnQuery(Doctrine_Query $query, $field, $value)
{
$rootAlias = $query->getRootAlias();
return $query->addWhere(
''.$rootAlias.'.name LIKE ? OR '.$rootAlias.'.name_full LIKE ?',
array($value, $value)
);
}