Question

i have an article document, for which i keep track of the read count. Now i want to run a query that would return the article which has the highest read count.

How would i go about this using doctrine odm?

thanks

Was it helpful?

Solution

Haven't really worked with the ODM all that often yet, but I believe you could do it like this:

$dm->createQueryBuilder('Article')->sort('readCount', 'desc')->limit(1)->getQuery()->execute();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top