On Fri, Jul 20, 2012 at 6:21 PM, Muhaimen Ezabbad <mezabbad@gmail.com> wrote:
Hi gurus,
the same code worked fine for all tables except this table "users",
I have an array which contains the user data:
e.g.
<?php
$d = array(
'User' => array(
'id' => 3,
'username' => 'user',
)
);
?>
I check if the user id is exists in the array if it's exists then I set the the model id the same as the id in the array:
<?php
$this->User->id = $d['User']['id'];
?>
Then I use the save function:
<?php
$this->User->save($d);
?>
but I found the the generated query is looks like this, and this happens for all the rows:
(( UPDATE `dbname`.`users` set id=3, `username`='user' WHERE `dbname`.`users`.`id` = '1' ))
I didn't find why it's updating the the first row all the time !!
When I check for the Model id it says it's 3 but when I want to update it updates the row #1 ???
any help ?
hai..
if u want to update into your table then i may suggest this code......
$this->User->id = $d['User']['id'];
$this->User->set($d);
if($this->User->save()){
echo "success";
}
i hope this will work for u
thanks.........
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment