<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: A black sheep with the name Model::updateAll()</title>
	<atom:link href="http://cakebaker.42dh.com/2007/12/12/a-black-sheep-with-the-name-modelupdateall/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com/2007/12/12/a-black-sheep-with-the-name-modelupdateall/</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Tue, 31 Jan 2012 15:12:14 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: redthor</title>
		<link>http://cakebaker.42dh.com/2007/12/12/a-black-sheep-with-the-name-modelupdateall/comment-page-1/#comment-238460</link>
		<dc:creator>redthor</dc:creator>
		<pubDate>Tue, 08 Nov 2011 00:03:49 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/12/12/a-black-sheep-with-the-name-modelupdateall/#comment-238460</guid>
		<description>Note, updateAll doesn&#039;t quote field values:
http://cakephp.lighthouseapp.com/projects/42648/tickets/970-updateall-doesnt-quote-the-data-fields

And also see &quot;&#039;Awesome&#039;&quot; here:
https://github.com/cakephp/cakephp/blob/1.3/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php#L875

This means you have to quote strings your self.</description>
		<content:encoded><![CDATA[<p>Note, updateAll doesn&#8217;t quote field values:<br />
<a href="http://cakephp.lighthouseapp.com/projects/42648/tickets/970-updateall-doesnt-quote-the-data-fields" rel="nofollow">http://cakephp.lighthouseapp.com/projects/42648/tickets/970-updateall-doesnt-quote-the-data-fields</a></p>
<p>And also see &#8220;&#8216;Awesome&#8217;&#8221; here:<br />
<a href="https://github.com/cakephp/cakephp/blob/1.3/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php#L875" rel="nofollow">https://github.com/cakephp/cakephp/blob/1.3/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php#L875</a></p>
<p>This means you have to quote strings your self.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2007/12/12/a-black-sheep-with-the-name-modelupdateall/comment-page-1/#comment-132294</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Thu, 09 Jul 2009 15:00:09 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/12/12/a-black-sheep-with-the-name-modelupdateall/#comment-132294</guid>
		<description>@xkunalx: Thanks for your comment!

Well, it seems like you have to treat the dates as strings, and so you have to use:
&lt;pre&gt;
&lt;code&gt;
‘trial_invoked’ =&gt; &quot;&#039;&quot; . date(”Y-m-d H:i:s”) . &quot;&#039;&quot;,
&lt;/code&gt;
&lt;/pre&gt;
Hope that helps!</description>
		<content:encoded><![CDATA[<p>@xkunalx: Thanks for your comment!</p>
<p>Well, it seems like you have to treat the dates as strings, and so you have to use:</p>
<pre>
<code>‘trial_invoked’ =&gt; "'" . date(”Y-m-d H:i:s”) . "'",</code>
</pre>
<p>Hope that helps!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: xkunalx</title>
		<link>http://cakebaker.42dh.com/2007/12/12/a-black-sheep-with-the-name-modelupdateall/comment-page-1/#comment-132259</link>
		<dc:creator>xkunalx</dc:creator>
		<pubDate>Thu, 09 Jul 2009 05:19:12 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/12/12/a-black-sheep-with-the-name-modelupdateall/#comment-132259</guid>
		<description>Daniel, thanks this was just what I was looking for. But I STILL cant get it to work. DOes updateAll() allow me to use Invoice-&gt;User-&gt;updateAll() ?

That fails with a SQL error (shown below). If i remove the condition it works..but I need to add a condition here.

        $this-&gt;Invoice-&gt;User-&gt;updateAll( array(
                    &#039;plan_id&#039; =&gt; $trial_plan_id,
                    &#039;trial_invoked&#039; =&gt; date(&quot;Y-m-d H:i:s&quot;),
                    &#039;trial_endtime&#039; =&gt; date(&quot;Y-m-d H:i:s&quot;, $trial_endtime),
                    ),
                    array(&#039;id ==&#039; =&gt; &quot;1&quot;)
                );
 


SQL error
SQL Error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near &#039;22:13:36, `User`.`trial_endtime` = 2009-07-15 22:13:36  WHERE `id` = 1&#039; at line 1 [CORE\cake\libs\model\datasources\dbo_source.php, line 525]
Query: UPDATE `users` AS `User` LEFT JOIN `plans` AS `Plan` ON (`User`.`plan_id` = `Plan`.`id`) SET `User`.`plan_id` = 2, `User`.`trial_invoked` = 2009-07-08 22:13:36, `User`.`trial_endtime` = 2009-07-15 22:13:36  WHERE `id` = 1</description>
		<content:encoded><![CDATA[<p>Daniel, thanks this was just what I was looking for. But I STILL cant get it to work. DOes updateAll() allow me to use Invoice-&gt;User-&gt;updateAll() ?</p>
<p>That fails with a SQL error (shown below). If i remove the condition it works..but I need to add a condition here.</p>
<p>        $this-&gt;Invoice-&gt;User-&gt;updateAll( array(<br />
                    &#8216;plan_id&#8217; =&gt; $trial_plan_id,<br />
                    &#8216;trial_invoked&#8217; =&gt; date(&#8220;Y-m-d H:i:s&#8221;),<br />
                    &#8216;trial_endtime&#8217; =&gt; date(&#8220;Y-m-d H:i:s&#8221;, $trial_endtime),<br />
                    ),<br />
                    array(&#8216;id ==&#8217; =&gt; &#8220;1&#8243;)<br />
                );</p>
<p>SQL error<br />
SQL Error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near &#8217;22:13:36, `User`.`trial_endtime` = 2009-07-15 22:13:36  WHERE `id` = 1&#8242; at line 1 [CORE\cake\libs\model\datasources\dbo_source.php, line 525]<br />
Query: UPDATE `users` AS `User` LEFT JOIN `plans` AS `Plan` ON (`User`.`plan_id` = `Plan`.`id`) SET `User`.`plan_id` = 2, `User`.`trial_invoked` = 2009-07-08 22:13:36, `User`.`trial_endtime` = 2009-07-15 22:13:36  WHERE `id` = 1</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2007/12/12/a-black-sheep-with-the-name-modelupdateall/comment-page-1/#comment-114352</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Wed, 10 Dec 2008 16:14:23 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/12/12/a-black-sheep-with-the-name-modelupdateall/#comment-114352</guid>
		<description>@pragnatek: You are welcome! And good luck with your project!</description>
		<content:encoded><![CDATA[<p>@pragnatek: You are welcome! And good luck with your project!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pragnatek</title>
		<link>http://cakebaker.42dh.com/2007/12/12/a-black-sheep-with-the-name-modelupdateall/comment-page-1/#comment-114332</link>
		<dc:creator>pragnatek</dc:creator>
		<pubDate>Tue, 09 Dec 2008 17:04:20 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/12/12/a-black-sheep-with-the-name-modelupdateall/#comment-114332</guid>
		<description>Thanks cakebaker,

I just couldn&#039;t get the syntax of updateAll() correct until I found your article.

Thanks</description>
		<content:encoded><![CDATA[<p>Thanks cakebaker,</p>
<p>I just couldn&#8217;t get the syntax of updateAll() correct until I found your article.</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2007/12/12/a-black-sheep-with-the-name-modelupdateall/comment-page-1/#comment-100789</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Mon, 28 Jul 2008 14:52:24 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/12/12/a-black-sheep-with-the-name-modelupdateall/#comment-100789</guid>
		<description>@Bruno: Thanks for the hint!</description>
		<content:encoded><![CDATA[<p>@Bruno: Thanks for the hint!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bruno Bergher</title>
		<link>http://cakebaker.42dh.com/2007/12/12/a-black-sheep-with-the-name-modelupdateall/comment-page-1/#comment-100423</link>
		<dc:creator>Bruno Bergher</dc:creator>
		<pubDate>Fri, 25 Jul 2008 16:32:55 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/12/12/a-black-sheep-with-the-name-modelupdateall/#comment-100423</guid>
		<description>Hi,

I ended up here while looking for a solution to my problem: my $model-&gt;updateAll(...) calls where returning true even if no rows had been updated.

I then realized it&#039;s not a Cake problem, but a logic error by myself. I&#039;m writing just to give the tip to someone which might have the same problem.

If you need to check if an update was successful in the sense of actuallt changing something, use the return of $model-&gt;getAffectedRows() after the call to $model-&gt;updateAll(...) to determine it.

That&#039;s it. Thanks for the space : )</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I ended up here while looking for a solution to my problem: my $model-&gt;updateAll(&#8230;) calls where returning true even if no rows had been updated.</p>
<p>I then realized it&#8217;s not a Cake problem, but a logic error by myself. I&#8217;m writing just to give the tip to someone which might have the same problem.</p>
<p>If you need to check if an update was successful in the sense of actuallt changing something, use the return of $model-&gt;getAffectedRows() after the call to $model-&gt;updateAll(&#8230;) to determine it.</p>
<p>That&#8217;s it. Thanks for the space : )</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2007/12/12/a-black-sheep-with-the-name-modelupdateall/comment-page-1/#comment-74336</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Fri, 14 Mar 2008 17:44:03 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/12/12/a-black-sheep-with-the-name-modelupdateall/#comment-74336</guid>
		<description>@Abhimanyu: *g*</description>
		<content:encoded><![CDATA[<p>@Abhimanyu: *g*</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Abhimanyu Grover</title>
		<link>http://cakebaker.42dh.com/2007/12/12/a-black-sheep-with-the-name-modelupdateall/comment-page-1/#comment-73975</link>
		<dc:creator>Abhimanyu Grover</dc:creator>
		<pubDate>Thu, 13 Mar 2008 11:21:45 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/12/12/a-black-sheep-with-the-name-modelupdateall/#comment-73975</guid>
		<description>LOL, I can&#039;t believe I just used &quot;cakebaker blacksheep&quot; keywords to find this article..</description>
		<content:encoded><![CDATA[<p>LOL, I can&#8217;t believe I just used &#8220;cakebaker blacksheep&#8221; keywords to find this article..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2007/12/12/a-black-sheep-with-the-name-modelupdateall/comment-page-1/#comment-54833</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Tue, 08 Jan 2008 18:01:41 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/12/12/a-black-sheep-with-the-name-modelupdateall/#comment-54833</guid>
		<description>@domin: Yes, some stuff is quite confusing...</description>
		<content:encoded><![CDATA[<p>@domin: Yes, some stuff is quite confusing&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

