Tuesday, March 1, 2011

Re: Help with update

On Tue, Mar 1, 2011 at 8:49 PM, lirc201 <brian.e.lavelle@gmail.com> wrote:
> Ryan,
>
> You are completely right about the atomic operation.  The below works
> well with a hard coded value, but I need to insert $quantity since
> that will vary based on the adjustment needed from an order or stock
> being added.  I'm stuck with the code change into the literal value
> there.
>
> $this->updateAll(
>        array('Venue.inventory' => 'Venue.inventory+$quantity'),
>        array('Venue.id' => $id));
>

You need to use double quotes to have the var evaluated.

array('Venue.inventory' => "Venue.inventory + ${quantity}")

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: