目标是通过我的view.ctp文件从我的数据库中打印出数据,并能够在我的本地主机中查看它。
以下是我正在使用的数据:
array(
'DataWriteError' => array(
'modified' => object(MongoDate) {
sec => (int) 1507762384
usec => (int) 402000
},
'created' => object(MongoDate) {
sec => (int) 1507762384
usec => (int) 402000
},
'errors' => array(
(int) 0 => array(
'index' => (int) 13370,
'code' => (int) 11000,
'message' => 'E11000 duplicate key error index: live_system.599c4ec3-0e24-408d-b8a6-067445404121.$Refcode_1 dup key: { : "VA1394315696" }'
),
(int) 1 => array(
'index' => (int) 14987,
'code' => (int) 11000,
'message' => 'E11000 duplicate key error index: live_system.599c4ec3-0e24-408d-b8a6-067445404121.$Refcode_1 dup key: { : "VA1394315697" }'
)
),
'campaign_id' => '59dea09d103fb4cb428fdef2',
'id' => '59dea0d0bed1ec43d21cf65b'
)
)
除了ERRORS之外,我还显示了其他所有内容。错误中有两个数组,我不能为我的生活找出我的代码错误的地方。
以下是我要回复的代码:
<td><?php foreach ($this->request->data['DataWriteError']['errors'] as $i => $item);
foreach ($item as $e => $etem) {
echo $this->request->data['DataWriteError']['errors']['index']['errors']['message'][$i];
echo $this->request->data['DataWriteError']['errors']['index']['code']['message'][$e];
} ?></td>
不确定我哪里出错了。如果有任何想法,请告诉我。谢谢!
答案 0 :(得分:0)
你试过打击:
foreach ($this->request->data['DataWriteError']['errors'] as $i => $item) {
echo $item['message'];
}