0

数据以这种形式出现

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

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'));

            }


    }

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

我没有得到我的代码中的问题所在

4

1 回答 1

1

像这样试试

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

代替

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

还要检查这个

$this->User->save($this->data['User'])做了$this->User->save($this->data)

于 2012-04-09T08:09:48.383 回答