bahamut100
bahamut100

Reputation: 1837

How to do a "Select count..." with symfony and propel?

I'm trying to do a very simple sql query like this, to a propel Criteria :

SELECT count(id_user) FROM myTable WHERE id_page = 5

I did'nt found informations on the documentation.

Have you an idea ??

Upvotes: 3

Views: 5480

Answers (2)

derphil
derphil

Reputation: 385

If you want to issue a SELECT COUNT(*) based on your current ModelCriteria you can also perform

$yourCriteria->count();

This will return you the number of results.

Upvotes: 2

Piskvor left the building
Piskvor left the building

Reputation: 92772

$c = new Criteria();
$c->add(myTablePeer::ID_PAGE,5);
$count = myTablePeer::doCount($c);

Upvotes: 4

Related Questions