我有一张table Commande
其中包含 prestataire_id
, date
, heure
,... 所以我想按日期重新组合表格。我试过了
$commande = $this->Commande->find('all', array('conditions' => array('Commande.prestataire_id' => $this->request->data['prestataire_id']),'order' => array('Commande.date' => 'DESC')));
json响应是这样的
{
"status": "Success",
"status_code": 200,
"message": "Commande trouvé",
"data": {
"get_Mission": {
"data": [
{
"Commande": {
"id": "475",
"date": "2018-04-20",
"heure": "10:00:00",
"date_created": "2018-04-19",
"heure_created": "17:11:39",
"date_accepted": "2018-04-19",
"heure_accepted": "17:12:35",
"delai": "00:00:56",
"date_fin": "0000-00-00",
"heure_fin": "00:00:00",
},
},
{
"Commande": {
"id": "476",
"date": "2018-04-20",
"heure": "10:07:00",
"date_created": "2018-04-19",
"heure_created": "17:13:12",
"date_accepted": "0000-00-00",
"heure_accepted": "00:00:00",
"delai": "0",
"date_fin": "0000-00-00",
"heure_fin": "00:00:00",
},
},
{
"Commande": {
"id": "477",
"date": "2018-04-19",
"heure": "17:13:00",
"date_created": "2018-04-19",
"heure_created": "17:13:48",
"date_accepted": "2018-04-19",
"heure_accepted": "17:14:23",
"delai": "00:00:35",
"date_fin": "0000-00-00",
"heure_fin": "00:00:00",
},
}
]
}
}
}
但我希望他们像数据一样按日期重新组合 ["2018-04-20"]-> {commande,commande}
, ["2018-04-19"]->{"commande}
有什么建议吗?
1条答案
按热度按时间zd287kbt1#
您可以尝试将月份设置为数组键。
并在设置后重新使用$examplearray。