문제

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