That's working perfectly now using the HYDRATE_RECORD and looping - I
only had to change the query to group by r.id so it shows all requests
with or without a comment made.
Very much appreciated.
On May 13, 5:02 pm, grahamj42 wrote:
> $collection is a Doctrine_Collection object. This has a metho
$collection is a Doctrine_Collection object. This has a method get()
which can take a row number and returns a Doctrine_Record object.
The Doctrine-Record object can be accessed by field name, so
$collection->get(0)->title should return the title of the first
request.
Alternatively, you can use H
The simplified DQL looks good and returns the correct rows including
the last created_at so definite progress.
You mentioned using $collection=$q-
>execute(array(),Doctrine_Core::HYDRATE_RECORD); // to retrieve all
the records
How exactly would I be able to use this to pull the comment's last
dat
I would start by simplifying the query:
SELECT r.*, MAX(c.created_at) AS last_comment
FROM request r LEFT JOIN comment c on r.id=c.request_id
GROUP BY c.request_id;
This can be expressed using DQL as:
$q=Doctrine_Query::create()->select( 'r.*, MAX(c.created_at) AS
last_comment' )->from( 'req