Hi guys, I'm getting used to the Model stuff with phalcon. I want to do a query similar to this one:
SELECT pid, MAX(date) as last
FROM Purchases
WHERE pid IN ('$strIDQuery')
GROUP BY pid
Here $strIDQuery=('09282',11811','32762')
So as you can see, I'm trying to retrieve the last date from each ID I pass trough the array. How can I do this with Phalcon:
I have this code:
$lastDates = Purchases::findFirst(
array(
"conditions" => "pid = '09282'",
"order" => "date DESC",
'format' => 'd-m-Y'
)
);
This code returns the last date of the pid=09282, BUT I want to pass many values and get a list of the last dates of each value. (What I'm doing with the IN command with my query above).
So, how can I achieve the results of the query above, with the phalcon models? Thank you!