Thursday, September 8, 2011

Re: need help in updateAll

You don't need to use updateAll. save will do all the job to create or update a record in db.

You also need to put the line:

$this->$table->create(); before save a new record to db

 $this->loadModel($table);
                $row =
$this->$table->find('count',array('conditions'=>array('user_id'=>$id)));
                if($row == 0){
               $this->$table->create();
               $this->$table->set(array('column' => 1, 'position'
=>1,'user_id'=>$id));
                $this->$table->save();
                }
               

--
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: