Reputation: 3015
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
Upvotes: 0
Views: 386
Reputation: 2860
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)))
Upvotes: 2
Reputation: 13952
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.
Upvotes: 0