【发布时间】:2020-06-25 06:09:23
【问题描述】:
这是我的控制器 =>
当我使用 deleteAll() 我得到这个错误 => 错误:SQLSTATE[21000]:基数违规:1241 操作数应包含 1 列
当我使用 delete() 我得到这个错误 => 错误:未知方法是新的
public function addSolution($ids = null)
{
$user_id=$this->Auth->User('id');
$city_id=$this->Auth->User('city_id');
$location_id=$this->Auth->User('location_id');
$this->viewBuilder()->layout('super_admin_layout');
$id = $this->EncryptingDecrypting->decryptData($ids);
$customerProblem = $this->CustomerProblems->get($id, [
'contain' => []
]);
$cust_id = $customerProblem['customer_id'];
$order_no = $customerProblem['order_no'];
if ($this->request->is(['patch', 'post', 'put'])) {
$customerProblem = $this->CustomerProblems->patchEntity($customerProblem, $this->request->getData());
$search=$this->request->getData();
$solutions=$this->request->getData()['solution'];
$delete = $this->CustomerProblems->find()->where([
'customer_id' => $search['customer_id'],
'mobile_no' => $search['mobile_no'],
'order_no' => $search['order_no'],
'problem' => $search['problem'],
'resolve_status' => $search['resolve_status'],
'status' => $search['status']
]);
if($this->CustomerProblems->deleteAll($delete)){
foreach ($solutions as $solution) {
$customerProblem = $this->CustomerProblems->newEntity();
$customerProblem->city_id = $city_id;
$customerProblem->created_by = $user_id;
$customerProblem->customer_id = $this->request->getData()['customer_id'];
$customerProblem->mobile_no = $this->request->getData()['mobile_no'];
$customerProblem->order_no = $this->request->getData()['order_no'];
$customerProblem->problem = $this->request->getData()['problem'];
$customerProblem->resolve_status = $this->request->getData()['resolve_status'];
$customerProblem->status = $this->request->getData()['status'];
$customerProblem->solution = $solution;
$this->CustomerProblems->save($customerProblem);
}
$this->Flash->success(__('The customer problem has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The customer problem could not be saved. Please, try again.'));
}
$customers=$this->CustomerProblems->Customers->find()->where(['Customers.id'=>$cust_id,'Customers.status'=>'Active']);
$customer=[];
foreach($customers as $data1){
$customer[]= ['value'=>$data1->id,'text'=>ucwords($data1->name)." (".$data1->username.")"];
}
$getAllSolution = $this->CustomerProblems->find()->where(['CustomerProblems.order_no'=>$order_no,'CustomerProblems.status'=>'Active'])->extract('solution');
$this->set(compact('customerProblem','customer','getAllSolution'));
}
【问题讨论】:
-
这显示了什么:
echo $this->CustomerProblems->find()->where($delete)->sql();
标签: php mysql sql cakephp-3.0