我试图在YII1中查询4个表,在获得结果后,我试图将它们分组,然后进行排序。但排序工作不正常。
这是我的代码
$criteria=new CDbCriteria;
$criteria->select = 't.log_id,t.message, t.date_added';
$criteria->with = array(
'camp' => array(
'select' => 'camp.name',
'joinType' => 'INNER JOIN',
'together' => true,
'customer' => array(
'select' => 'cus.id, customer.name,
'joinType' => 'INNER JOIN',
'together' => true,
),
),
),
'driver' => array(
'select' => 'driver.name',
'joinType' => 'INNER JOIN',
'together' => true,
),
);
$criteria->addCondition('t.message=\'OK\'');
$criteria->addInCondition('camp.status', array('done', 'processing', 'pending'));
//i have also use this on this place
//$criteria->order = 't.date_added DESC';
//i have also use this on this place
//$criteria->order = 't.log_id DESC';
$criteria->group = 't.camp_id,driver.driver_id';
$criteria->order = 't.date_added DESC';
//i have also use this on this
//$criteria->order = 't.log_id DESC';
$dataProvider = new CActiveDataProvider('modelname', array(
'criteria' => $criteria,
));
$dataArray=$dataProvider->getData();
foreach($dataArray as $item1)
{
echo $item1->log_id."<br>";
}
现在当我第一次运行此应用程序时,我得到了这个输出
1242206
1235814
1234853
看起来我的桌子最后一次log_id是1242206,但我的桌子最后是
1243104
在所有条件相同的情况下,它不会排序。
感谢您的帮助。