Question

I have relation of relation of relation query thus and i want to select only the most recently created record for table CancellationRequest c.

Anyone any idea if this is/should be possible and how?

Doctrine_Query::create()
    ->from('UserNotificationTo unt')
    ->leftJoin('unt.Notification un')
    ->leftJoin('un.QuoteOrder qo')
    ->leftJoin('qo.CancellationRequest c')
    ->where('un.sent_external = 0')
    ->andWhere('c.updated_at *IS THE MOST RECENTLY CREATED ONE*')
    ->execute();
Was it helpful?

Solution

You have to do ORDER BY c.updated_at

Then you can do:

$userNotifcation->getQuoteOrder()->getCancellationRequest()->first()

to get the most recent one

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top