<?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: How to apply a beforeSave to certain models only</title>
	<atom:link href="http://cakebaker.42dh.com/2006/08/05/how-to-apply-a-beforesave-to-certain-models-only/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com/2006/08/05/how-to-apply-a-beforesave-to-certain-models-only/</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: cakebaker</title>
		<link>http://cakebaker.42dh.com/2006/08/05/how-to-apply-a-beforesave-to-certain-models-only/comment-page-1/#comment-650</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Tue, 08 Aug 2006 09:52:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=238#comment-650</guid>
		<description>@Brandon P: Using flags is a good idea. Calling afterFind() after findCount() makes imho not much sense, at least I don&#039;t see a use case for that at the moment.</description>
		<content:encoded><![CDATA[<p>@Brandon P: Using flags is a good idea. Calling afterFind() after findCount() makes imho not much sense, at least I don&#8217;t see a use case for that at the moment.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brandon P</title>
		<link>http://cakebaker.42dh.com/2006/08/05/how-to-apply-a-beforesave-to-certain-models-only/comment-page-1/#comment-648</link>
		<dc:creator>Brandon P</dc:creator>
		<pubDate>Sat, 05 Aug 2006 20:29:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=238#comment-648</guid>
		<description>I run into this question many times but mostly doesn&#039;t.

Example: I have a counterCache implemntation that automatically updates a count field on an associated table (belongsTo relationship)

ForumPost belongsTo Forum (counterCache: forum_post_count)

So everytime a ForumPost is created it will count up and store all ForumPosts&#039; by counting with the foriegnKey (in this case forum_id) as the condition.  Quite useful and VERY helpful for stuff like Categories.product_count, Forum.forum_post_count, etc ..

It would be nice to take this 1 step futher and suggest the use of flags for turning off these callbacks:

$this-&gt;ForumPost-&gt;_afterSave = false;

Also, I think findCount () should NOT call the afterFind () callback for obvious reasons.  Agree/disagree?</description>
		<content:encoded><![CDATA[<p>I run into this question many times but mostly doesn&#8217;t.</p>
<p>Example: I have a counterCache implemntation that automatically updates a count field on an associated table (belongsTo relationship)</p>
<p>ForumPost belongsTo Forum (counterCache: forum_post_count)</p>
<p>So everytime a ForumPost is created it will count up and store all ForumPosts&#8217; by counting with the foriegnKey (in this case forum_id) as the condition.  Quite useful and VERY helpful for stuff like Categories.product_count, Forum.forum_post_count, etc ..</p>
<p>It would be nice to take this 1 step futher and suggest the use of flags for turning off these callbacks:</p>
<p>$this-&gt;ForumPost-&gt;_afterSave = false;</p>
<p>Also, I think findCount () should NOT call the afterFind () callback for obvious reasons.  Agree/disagree?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2006/08/05/how-to-apply-a-beforesave-to-certain-models-only/comment-page-1/#comment-649</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Sat, 05 Aug 2006 16:42:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=238#comment-649</guid>
		<description>Yes, you are right, that&#039;s a cleaner solution. Thanks.</description>
		<content:encoded><![CDATA[<p>Yes, you are right, that&#8217;s a cleaner solution. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patrice</title>
		<link>http://cakebaker.42dh.com/2006/08/05/how-to-apply-a-beforesave-to-certain-models-only/comment-page-1/#comment-647</link>
		<dc:creator>Patrice</dc:creator>
		<pubDate>Sat, 05 Aug 2006 15:01:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=238#comment-647</guid>
		<description>Never worked with CakePHP, but I guess MyModel inherits from AppModel? In that case wouldn&#039;t it be cleaner to just override beforeSave() in MyModel and do nothing?</description>
		<content:encoded><![CDATA[<p>Never worked with CakePHP, but I guess MyModel inherits from AppModel? In that case wouldn&#8217;t it be cleaner to just override beforeSave() in MyModel and do nothing?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

