Re: Update field in associated model???

2014-05-30 Thread haptiK
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

Re: Update field in associated model???

2011-12-11 Thread flosky
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

Re: Update field in associated model???

2011-12-11 Thread Geoff Douglas
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

Re: Update field in associated model???

2011-12-10 Thread flosky
@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

Re: Update field in associated model???

2011-12-10 Thread Geoff Douglas
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

Re: Update field in associated model???

2011-12-09 Thread Andras Kende
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,

Re: Update field in associated model???

2011-12-09 Thread Geoff Douglas
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)){