Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cakephp查询更新失败_Php_Mysql_Sql_Cakephp - Fatal编程技术网

Cakephp查询更新失败

Cakephp查询更新失败,php,mysql,sql,cakephp,Php,Mysql,Sql,Cakephp,我是Cakephp的新手 我试图获取post数据并更新发票表。但我应该从post数据中获取医生id的值,并从医生表和更新发票表中获取与医生id相关的转诊费用 我尝试使用此代码,但没有成功。请帮帮我 if ($this->request->is('post')) { $this->Invoice->create(); if ($this->Invoice->save($this->request->data)) {

我是Cakephp的新手 我试图获取post数据并更新发票表。但我应该从post数据中获取医生id的值,并从医生表和更新发票表中获取与医生id相关的转诊费用

我尝试使用此代码,但没有成功。请帮帮我

if ($this->request->is('post')) {

    $this->Invoice->create();
    if ($this->Invoice->save($this->request->data)) {
        $refid = $this->request->data['Invoice']['refid'];  
        print_r($refid);
        $doctor = $this->Doctor->findById($refid);
        $rfee = $doctor['Doctor']['rfee'];
        $invoice_number = $this->request->data['Invoice']['invoice_number'];
        $invoice = $this->Invoice->findByInvoiceNumber($invoice_number);
        $invoice_id = $invoice['Invoice']['id'];
        $this->Invoice->id = $invoice_id;
        $this->Invoice->save('refee', '200');
        $this->Session->setFlash('Invoice Successfully Added');

        $this->redirect(array('controller' => 'invoices', 'action' => 'edit', $invoice_id));
   } else {
       $this->Session->setFlash('Unable To Add Invoice');
   }
}

尝试通过此更新记录

$this->Invoice->save($this->request->data,false);

如果记录更新成功,则表示发布数据的某些验证规则失败。如果此问题不能通过此方法解决,则检查您的POST数据中是否存在发票表的PK,如果没有,则设置它并重新运行代码

尝试通过此方法更新记录

$this->Invoice->save($this->request->data,false);

如果记录更新成功,则表示发布数据的某些验证规则失败。如果此问题不能通过这种方式解决,则检查发票表的PK是否存在于您的POST数据中,如果不存在,则设置并重新运行您的代码

实际上,我想要的是在使用发票表中的POST数据更新后,根据post数据中的refid从医生表中获取rfee,并使用先前更新的发票表进行更新实际上,我想要的是在使用发票表中的post数据进行更新后,根据post数据中的refid从医生表中获取rfee,并使用先前更新的发票表进行更新