<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>{5} Setfive - Talking to the World &#187; primary keys</title>
	<atom:link href="http://shout.setfive.com/tag/primary-keys/feed/" rel="self" type="application/rss+xml" />
	<link>http://shout.setfive.com</link>
	<description></description>
	<lastBuildDate>Fri, 03 Sep 2010 18:48:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Propel and Primary keys</title>
		<link>http://shout.setfive.com/2008/08/14/propel-and-primary-keys/</link>
		<comments>http://shout.setfive.com/2008/08/14/propel-and-primary-keys/#comments</comments>
		<pubDate>Fri, 15 Aug 2008 00:42:01 +0000</pubDate>
		<dc:creator>Matt Daum</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[primary keys]]></category>
		<category><![CDATA[Propel]]></category>

		<guid isPermaLink="false">http://shout.setfive.com/?p=15</guid>
		<description><![CDATA[Today I was writing an administrator backend for a project we have. I had the code: $old_feeds=RssFeedRelationPeer::doSelect($c); if(count($old_feeds)>0){ foreach ($old_feeds as $old) $old->delete(); } I was trying to remove some old foreign constraints before I deleted the main object, however, for the longest time the &#8220;$old&#8221; objects were not deleting, but no errors were being [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was writing an administrator backend for a project we have.  I had the code:</p>
<pre class="php" name="code">
$old_feeds=RssFeedRelationPeer::doSelect($c);
if(count($old_feeds)>0){
   foreach ($old_feeds as $old) $old->delete();
}</pre>
<p>I was trying to remove some old foreign constraints before I deleted the main object, however, for the longest time the &#8220;$old&#8221; objects were not deleting, but no errors were being thrown.  I did the usual debugging, added a die() statement inside the count, it was going there.  I added a die statement in the foreach, it went there.  I thought, &#8220;It must not be pulling the right &#8216;old&#8217; objects.&#8221; I then added a <code>$old->getName();</code> to see exactly what objects it was going through-they were the right ones.  It made no sense.  I next tired after the <code>$old->delete();</code>to add a <code>$old->save();</code>.  The error I received was &#8220;You cannot save an object that has been deleted.&#8221;  This didn&#8217;t make sense, since the object was still in the database.  It hit me then, I had this problem in the past.  Propel hates tables without foreign keys.  I quickly just added a simple foreign key to the model, and the delete statements worked.</p>
<p><strong>Moral:</strong>  If dealing with Propel and you are getting some unexpected behavior, with zero errors, check to see if you have a primary key; it may save you hours of head banging. </p>
]]></content:encoded>
			<wfw:commentRss>http://shout.setfive.com/2008/08/14/propel-and-primary-keys/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
