gpt4 book ai didi

php - 如果日期相等,Array_multisort 将失败

转载 作者:可可西里 更新时间:2023-10-31 23:46:11 27 4
gpt4 key购买 nike

我正在使用 yii 框架并使用 CArrayDataProvider 因为我的数据提供者包含 3 个表。但是如果我在其中使用 Sort

$sort = new CSort;
$sort->defaultOrder = 'created DESC';
$dataProvidermain=new CArrayDataProvider($data, array(
'id'=>'user',
'sort' => $sort,
'pagination'=>array(
'pageSize'=>20,
),
));

报错

Fatal error: Nesting level too deep - recursive dependency? in /var/www/goalsurf/framework/web/CArrayDataProvider.php on line 151

经过调试,我知道当 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());

最佳答案

试试看:$sort->defaultOrder = 'created DESC, id ASC';

关于php - 如果日期相等,Array_multisort 将失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35628272/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com