0

I've been looking for hours to get the right syntax for the doctrine query builder. I need to get the oldest value in the DB.

colums:

id, dateCreated, value 

query: (that doesn't works)

->select('c') ->where( $qb->expr()->eq('c.dateCreated', $qb->expr()->min('c.dateCreated')) ) 

can someone tells me how to build the right query for my need please. Thanks guys!

1
  • 1
    Just sort the result set by dateCreated with addition of limiting to 1 result and you should be good to go. Commented Mar 23, 2016 at 20:42

1 Answer 1

2

You should just sort returned values and only get the first one (depending on the ordering)

$select('c')->orderBy('c.expDate', 'ASC')->setMaxResults(1); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.