简体   繁体   English

更新查询在蛋糕 php 中不起作用

[英]update query not working in cake php

data is coming this form数据来自这种形式

Array
(
[User] => Array
    (
        [first_name] => sxsaxs
        [last_name] => sdsdsd
        [contact_no] => 9569908024
        [address_1] => sdasd
        [address_2] => dsdsdsd
        [country_id] => 1
        [state_id] => 1
        [city_id] => 1
    )

)

users_controller.php users_controller.php

public function my_account_edit(){

 if(!empty($this->data))
    {
         $this->User->id = $this->Auth->user('id');

     //   echo  $id= $this->User->id = $this->Auth->user('id'); it's working echo id

        if($this->User->save($this->data['User']))
            {

               $this->Session->setFlash("Account has been saved");
               $this->redirect(array('action' => 'my_account'));

            }


    }

but update query not working where id = $this->Auth->user('id');但更新查询不起作用 where id = $this->Auth->user('id');

i am not getting where is problem in my code我不知道我的代码哪里有问题

Try like this,像这样尝试,

$this->data['User']['id'] = $this->Auth->user('id');

instead of代替

$this->User->id = $this->Auth->user('id');

Also check this还要检查这个

$this->User->save($this->data['User']) make it $this->User->save($this->data) $this->User->save($this->data['User'])让它$this->User->save($this->data)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM