我正在使用yii
框架并使用CArrayDataProvider
,因为我的数据提供程序包含3个表。但如果我在此使用Sort
。
$sort = new CSort;
$sort->defaultOrder = 'created DESC';
$dataProvidermain=new CArrayDataProvider($data, array(
'id'=>'user',
'sort' => $sort,
'pagination'=>array(
'pageSize'=>20,
),
));
抛出错误
致命错误:嵌套级别太深 - 递归依赖?在 第151行/var/www/goalsurf/framework/web/CArrayDataProvider.php
调试后,我知道当2个或更多元素的日期相等时,它会抛出此错误。我有三个具有相同日期的实体。2016-02-06 10:10:51
。如果我更改2条记录的日期,它就可以了。试图从过去2天解决这个问题。搜索谷歌但没有解决方案。
请帮帮我。
更新 这是数组格式
[68] => Tasks Object
(
[taskmodel] => 1
[quickacent] => 15
[dailygoal] =>
[weeklygoal] =>
[dailygoal2] =>
[_new:CActiveRecord:private] =>
[_attributes:CActiveRecord:private] => Array
(
[id] => 563
[guid] => 650c7572-3fae-4f9a-a476-8de6a21c329e
[user_id] => 44
[deli_id] => 0
[branch_id] => 0
[main_goal_id] => 0
[title] => Buy Babycon Dress
[thumb_ext] =>
[description] =>
[ecv] =>
[isSpam] => 0
[displayorder] => 0
[created] => 2016-02-06 10:10:52
[modified] => 2016-02-06 10:10:52
)
)
)
更新2
我的$data
变量是
$dataProvider=new CActiveDataProvider('Goals', array('criteria' => $criteria,'pagination'=>false));
$dataProvider2=new CActiveDataProvider('Tasks', array('criteria' => $criteria2,'pagination'=>false));
$dataProvider3=new CActiveDataProvider('TasksDaily', array('criteria' => $criteria2,'pagination'=>false));
//echo "<pre>"; print_r($dataProvider2->getData()); die;
$data=array_merge($dataProvider->getData(),$dataProvider2->getData(),$dataProvider3->getData());
答案 0 :(得分:0)
试试:$sort->defaultOrder = 'created DESC, id ASC';