CakePHP do exactly this if you use InnoDB tables. On Mar 4, 6:15 am, C Gábor <czig...@gmail.com> wrote: > Just came across the same question. saveField() uses save(), so it > will just either call an INSERT or UPDATE, depending on whether it has > an id set or not. > > REPLACE INTO is a utterly useful SQL statement: > > You have a table with a id as the primary key, some unique column(s) > and then other data fields. If you want to update those other data > fields, but you don't now, whether there is already a row with the > unique value (in which case you would like to replace, update that > row) you can avoid the following logic: > > 1. start the transaction > 2. query the table with you unique value > 3. if (no rows returned) INSERT else UPDATE > 2. commit > > Can you mimic this in CakePHP somehow? Of course you can always use > Model->query(). > > Cheers, > G > > On Mar 3, 7:02 pm, genellern <genell...@gmail.com> wrote: > > > > > what if u use saveField ?? > > > $this->Model->saveField('field',$data); > > > this way u will only update the field u need > > > On 3 mar, 04:22, Geoff <ge...@prezence.co.za> wrote: > > > > Hey all. > > > > Has anybody needed to use the REPLACE INTO MySQL syntax within a Cake > > > application? That is, using the REPLACE INTO syntax as you would a > > > normal insert [through $Model->save()], as opposed to using raw > > > queries. > > > > If you did manage to get this working, could you please enlighten us > > > as to how you did so? Did you create a new DBO? Behaviours? > > > > I'd really appreciate any help anyone could supply. > > > > thanks, > > > Geoff
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en