我正在开发一个cakephp 2.x ......那么情节就是我正在向我的webapp发送消息......有近509条消息......问题是它将一些消息保存到数据库中一些消息让我在android控制台上出错了......所以首先我要问你们所有人认为实际问题在哪里或者可以说谎......而另一方面认为我有办法在未保存到数据库中的数据上抛出一些异常错误..所以我可以跟踪未保存到的特定消息并导致问题...我需要一些帮助来调试此代码
这是我的代码
public function message(){
$this->loadModel('Message');
if ($this->request->isPost()){
$json = $this->request->data('json');
$data = json_decode($json, TRUE);
foreach($data as $datas){
$date = $datas['date'];
$mobileNo = $datas['mobileNo'];
$mobileNo = AllSecure::replaceDashesAndSpaces($mobileNo);
$body = $datas['body'];
$timestamp = $date/1000;
$date = date('Y-m-d h:i' , $timestamp);
$this->request->data['Message']['mobileNo'] = $mobileNo;
$this->request->data['Message']['body'] = $datas['body'];
$this->request->data['Message']['type'] = $datas['type'];
$this->request->data['Message']['User_id'] = $datas['idUser'];
$this->request->data['Message']['dateTime'] = $date;
$count = $this->Message->checkTextMessages($mobileNo,$body,$date,$datas['idUser']);
if($mobileNo!=null){
if($count>0){
}else{
$this->Message->create();
$this->Message->save($this->request->data
}
}
}
}
}
答案 0 :(得分:0)
foreach($data as $datas){
$i=0
$this->request->data['Message'][$i]['mobileNo'] = $datas['mobileNo'];;
$this->request->data['Message'][$i]['body'] = $datas['body'];
$this->request->data['Message'][$i]['type'] = $datas['type'];
$this->request->data['Message'][$i]['User_id'] = $datas['idUser'];
$i++;
if($mobileNo!=null){
}
}
$isSave = $this->Message->saveAll($this->request->data["Message"]);
echo $isSave;