I known that in sql statement the latest reply can be get by adding “order by created DESC limit 0,1”
But how can i get it using QueryBuilder?
I have refered to the document of QueryBuilder . There is no limit() function.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Just use ->setMaxResults(1) to say “limit” with doctrine
And the doc’: http://www.doctrine-project.org/docs/orm/2.1/en/reference/query-builder.html#limiting-the-result ^^
But in this case you should use ->getSingleResult() instide of ->getResult(), without using limit. (It’s more appropriated !)