Re: Increment value using CakePHP model functions

2009-11-21 Thread Dave
Because I didn't know about it! Thank you so much Ma'moon! On Sat, Nov 21, 2009 at 3:31 PM, Ma'moon wrote: > ًWhy you're not using *Increment Behavior* > http://bakery.cakephp.org/articles/view/increment-behavior ?!! > > > On Sat, Nov 21, 2009 at 11:52 AM, Dave wrote: > >> Hehe it is close to o

Re: Increment value using CakePHP model functions

2009-11-21 Thread Ma'moon
ًWhy you're not using *Increment Behavior* http://bakery.cakephp.org/articles/view/increment-behavior ?!! On Sat, Nov 21, 2009 at 11:52 AM, Dave wrote: > Hehe it is close to on the money. I do appreciate your help. The goal of > this question was to increment a value with 1 query. You can do

Re: Increment value using CakePHP model functions

2009-11-21 Thread Dave
Hehe it is close to on the money. I do appreciate your help. The goal of this question was to increment a value with 1 query. You can do this with MySQL with a simple query settings field = field + 1. I was just wondering if there was a way to do this within the core as usually your fields are

Re: Increment value using CakePHP model functions

2009-11-20 Thread jburns
You are right. Can I ask if you are using recursion and containable? If so, you can be very specific about what tables, records and fields are returned. I'm still fairly new with Cake but have realised that it is a good thing to implement these in AppModel and then I have complete control over dat

Re: Increment value using CakePHP model functions

2009-11-20 Thread Dave
jburns, if you set your debug level to 2 you will see that performs 2 queries AND gets a bunch of data I don't need about the item... grigri that is very helpful to know that updateAll doesn't escape your arguments. I don't need to afterSave currently, but it is good to know I can do it the secon

Re: Increment value using CakePHP model functions

2009-11-20 Thread grigri
It's possible in two ways. First, you've got the `updateAll` function which doesn't escape or mess with your arguments: $this->Item->updateAll( array('Item.flags' => 'Item.flags + 1'), array('Item.id' => 666) ); One possible problem with this is that it will not call `afterSave`, trigger beh

Re: Increment value using CakePHP model functions

2009-11-20 Thread jburns
I think this might point you in the right direction: http://book.cakephp.org/view/75/Saving-Your-Data ,,,particularly this piece: $this->Post->read(null, 1); $this->Post->set(array( 'title' => 'New title', 'published' => false )); $this->Post->save(); On Nov 20, 12:46 pm, Dave

Increment value using CakePHP model functions

2009-11-20 Thread Dave
Hi everybody, I have a quick question that bugs me each time I run into it in a project, and then I promptly forget about it. It is an easy fix, but it is such common functionality that I feel there must be some way to do it within built in functions rather then a custom query. The issue is incr