spotorm / spot2

Spot v2.x DataMapper built on top of Doctrine's Database Abstraction Layer
http://phpdatamapper.com
BSD 3-Clause "New" or "Revised" License
601 stars 101 forks source link

How can a filter be made with having() #284

Open dertin opened 5 years ago

dertin commented 5 years ago

Hello, the following is what I want to do:

SELECT * FROM testing GROUP BY foo HAVING COUNT(foo) > 1

but it does not work.

$mapperTesting->all()->group(['foo'])->having(['COUNT(foo)' => '> 1'])->toArray();

Regards,

FlipEverything commented 5 years ago

I am really sorry for the late reply, but have you tried this?

$mapperTesting->all()->group(['foo'])->having(['COUNT(foo) >' => '1'])->toArray();

It translates to:

GROUP BY test_posts.status HAVING COUNT(status) >  ?