سؤال

in Cakephp if i have to update the record in some tables, i used update function

 $this->Userinfo->updateAll(
        array('number' => "'$number'"),
        array('User_id' => $userid)))

and the other way to update the record is to do this

i write query in my userinfo table in which i get the userid against the user.and then

   $this->Userinfo->id = $this->Userinfo->getUserid($userid);
   $this->Userinfo->save($data);

so now i want to ask what way is better .. do i have to use update or do i have to use save

هل كانت مفيدة؟

المحلول 2

If you're just saving one record, use the second version (save). UpdateAll is usually used when you're saving multiple records at the same time.

نصائح أخرى

That's totally depend on your requirement

Now if here you want to update just single record then go with

$this->Userinfo->id = $this->Userinfo->getUserid($userid);
$this->Userinfo->save($data);

And if you want to update more than one record in single query then go with

 $this->Userinfo->updateAll(
        array('number' => "'$number'"),
        array('User_id' => $userid)))
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top