Hi everybody,
I’m struggling with the following problem:
There’s a table with
id|internalID|name|date
internalID is a grouping ID, because an entry can have several "copies". But I want to show just the newest one (order by date). So I added some scopes:
public function scopes()
{
return array(
'latestProjects' => array(
'order' => 'date DESC',
),
'groupInternal' => array(
'group' => 'internalProjectID',
)
);
}
And in the Conroller I call:
$quotationData = new CActiveDataProvider(Project::model()->latestProjects()->groupInternal(), array());
I get grouped entries, but not with the latest entry first… It combines the SQL Statement (and as I googled, group by is executed before order by…).
How could I solve this problem?