With doctrine syntax using postgres as database, is it possible to generate a query like:
SELECT
DISTINCT ON (people.email)
*
FROM people
WHERE people.company SIMILAR TO '%companyA%|%companyB%|%...';
So far I have:
[...]
$query= Doctrine_Query::create()->from('People p')
->select('p.email, p.name, p.surname');
$alias= $query->getRootAlias();
foreach ($companies as $company){
$query->orWhere($alias.'.name ilike ?', '%'.$company.'%');
}
[...]
I’m interested in the equivalent of “DISTINCT ON” for Doctrine ORM
Thanks
It seems that Docrine doesn’t have a good way to use “DISTINCT ON”. Also I haven’t find a way using “DISTINCT” or ->distinct() that suits the needs I had (I got many crappy stuff when Doctrine builds the SQL query).
Finally I’ve done the DISTINCT ON stuff using a different approach. Here’s the SQL query I’m using now:
The Doctrine syntax I’ve used to generate it from symfony is more or less: