only time we use the $fields array in this manner, but then again
whenever I use updateAll() it's to change the value of some flags so
my value must have always been 1 or 0 and therefore worked without an
issue.
Learn something new every day :)
Paul.
On Aug 22, 8:14 am, ShadowCross <adri...@jps.net> wrote:
> In the updateAll() section of the CakePHP Book (http://
> book.cakephp.org/view/1031/Saving-Your-Data) has the following
> information box:
>
> The $fields array accepts SQL expressions. Literal values should be
> quoted manually.
>
> It's a bit terse, but basically it's saying that if you want to update
> a field with a specific string value, you need to include quotes as
> part of the string. Without the quotes, your string is interpreted as
> an SQL expression; so your database is thinking that sky is a column
> name and not a literal value. This allows you to reference columns in
> the "value", e.g. array('Post.counter' => 'counter + 1'). Since
> updateAll() automatically joins belongsTo tables, this can be
> particularly powerful. Note that this applies only to the $fields
> array, and differs significantly from the $conditions array.
>
> Your code should be:
>
> $this->Theme->updateAll(array('Theme.name' => '"' . $name . '"'),
> array('Theme.user_id' => $id));
--
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:
Post a Comment