You forgot to say Happy Coding!
On Sunday, 11 December 2011 19:58:23 UTC-8, Geoff Douglas wrote:
I am not sure about any one else... but for me I normally have the id from
either passing it in, or having it from related data. I must just not do a
lot of UPDATE-ing. :)
I do use this for
Thanks, Geoff, the single quotes did the trick.
I'm still surprized that this seems to be a very uncommon approach by
me.
Is everyone out there doing a find() query first to get the 'id' value
and then calling save()???
-flosky
--
Our newest site for the community: CakePHP Video Tutorials
I am not sure about any one else... but for me I normally have the id from
either passing it in, or having it from related data. I must just not do a
lot of UPDATE-ing. :)
I do use this for shell scripts more than web request type functions,
because my shell scripts are generally more prone to
@Andras: I tried that and get following error msg: SQLSTATE[42S22]:
Column not found: 1054 Unknown column 'jap' in 'field list'.
(I'm trying to set the 'prefered_lang' to 'jap').
@Geoff: I did that and it works. But I dont want to do an (in my
oppinion) unnecessary read operation.
Since I have a
I see, then updateAll() is the method that you want.
It appears by the error message that it's thinking that 'jap' is a field,
so maybe it's just in the wrong place? or maybe you have a comma instead of
a double arrow?
I ran a little test on my Cake 1.3 install and it worked as expected. Here
Its creates a new record since the primary key Setting.id is not specified..
you could :
$this-User-Setting-updateAll(
array('Setting.prefered_language' = $lang),
array('Setting.user_id = $user_id)
);
Andras Kende
http://www.kende.com
On Dec 9,
In Cake, or I guess in SQL rather, you need to tell the system which record
you want to update.
You are passing in data, with no primary key value specified. So, one way
to do this, would be:
$setting = $this-User-Setting-findByUserId($user_id);
if(!empty($setting)){