Re: problem in updateAll
How blind am I? I never spotted that with updateAll(), which is the 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: problem in updateAll
The problem is the value sky needs single quotes around it otherwise MySQL tries to find a field with that name. The bigger problem is I have no idea why Cake would take the value and not wrap it in single quotes as it always has done for me no matter what version I have used. What do you get if you echo debug($name);? There must be something odd with that variable for Cake to treat it differently. What happens if you change your call to: $this-Theme-updateAll( array('Theme.name' = 'sky'), array('Theme.user_id' = $id) ); HTH, Paul On Aug 21, 6:13 pm, taqman filler taqman...@gmail.com wrote: I use updateAll to change theme name $this-Theme-updateAll(array('Theme.name' = $name), array('Theme.user_id' = $id)); I got unknow column this sql UPDATE `themes` AS `Theme` SET `Theme`.`name` = sky WHERE `Theme`.`user_id` = 128 thank -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: problem in updateAll
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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
problem in updateAll
I use updateAll to change theme name $this-Theme-updateAll(array('Theme.name' = $name), array('Theme.user_id' = $id)); I got unknow column this sql UPDATE `themes` AS `Theme` SET `Theme`.`name` = sky WHERE `Theme`.`user_id` = 128 thank -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php