views:

26

answers:

1

Hi all,

I am using cakePHP 1.26.
I got some sample data in a Table which has got two field: {user_id, avatar}
I was trying to update an old record in the database :

 $who=$this->Session->read('user.user_id'); // 12 was retrieved in this case
 $c = "http://www.abc.com/myimage.gif";
 $this->Test->User->user_id = $who;
 $result = $this->Test->User->saveField('avatar',$c);
  if( $result==true){return "ok";}

When I checked the database, I saw a new record was creeated instead, but the old record with user_id 12 was not updated at all

Please help.

+2  A: 

The problem is here:

$this->Test->User->user_id = $who;

Assuming that you have normal CakePHP DB convention it should be:

$this->Test->User->id = $who;
Nik