<?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: Kohana ORM Tip : ORM Tree</title>
	<atom:link href="http://www.ninjapenguin.co.uk/blog/2008/09/25/kohana-orm-tip-orm-tree/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ninjapenguin.co.uk/blog/2008/09/25/kohana-orm-tip-orm-tree/</link>
	<description>Personal blog of Matthew Wells</description>
	<lastBuildDate>Tue, 30 Aug 2011 20:59:25 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Matt</title>
		<link>http://www.ninjapenguin.co.uk/blog/2008/09/25/kohana-orm-tip-orm-tree/comment-page-1/#comment-11430</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Sat, 24 Jul 2010 10:59:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.ninjapenguin.co.uk/blog/?p=38#comment-11430</guid>
		<description>Thanks very much! It was indeed at Newcastle as well by the way. Matt</description>
		<content:encoded><![CDATA[<p>Thanks very much! It was indeed at Newcastle as well by the way. Matt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Johnathan Au</title>
		<link>http://www.ninjapenguin.co.uk/blog/2008/09/25/kohana-orm-tip-orm-tree/comment-page-1/#comment-11424</link>
		<dc:creator>Johnathan Au</dc:creator>
		<pubDate>Fri, 23 Jul 2010 15:42:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.ninjapenguin.co.uk/blog/?p=38#comment-11424</guid>
		<description>Nice website. Was skimming through your dissertation and noticed that Jeff Yan was your supervisor. It wasn&#039;t Jeff Yan from Newcastle by any chance? I&#039;m studying CS there right now.</description>
		<content:encoded><![CDATA[<p>Nice website. Was skimming through your dissertation and noticed that Jeff Yan was your supervisor. It wasn&#8217;t Jeff Yan from Newcastle by any chance? I&#8217;m studying CS there right now.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Buchmann</title>
		<link>http://www.ninjapenguin.co.uk/blog/2008/09/25/kohana-orm-tip-orm-tree/comment-page-1/#comment-7195</link>
		<dc:creator>Peter Buchmann</dc:creator>
		<pubDate>Thu, 08 Oct 2009 07:21:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.ninjapenguin.co.uk/blog/?p=38#comment-7195</guid>
		<description>Great tutorial that was a big help to me, thanks a lot!</description>
		<content:encoded><![CDATA[<p>Great tutorial that was a big help to me, thanks a lot!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jyskal</title>
		<link>http://www.ninjapenguin.co.uk/blog/2008/09/25/kohana-orm-tip-orm-tree/comment-page-1/#comment-5890</link>
		<dc:creator>Jyskal</dc:creator>
		<pubDate>Sat, 27 Jun 2009 14:43:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.ninjapenguin.co.uk/blog/?p=38#comment-5890</guid>
		<description>@bumperbox &amp; Bicho44

Use protected $ORM_Tree_children instead of protected $children.

GreetZ</description>
		<content:encoded><![CDATA[<p>@bumperbox &amp; Bicho44</p>
<p>Use protected $ORM_Tree_children instead of protected $children.</p>
<p>GreetZ</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bicho44</title>
		<link>http://www.ninjapenguin.co.uk/blog/2008/09/25/kohana-orm-tip-orm-tree/comment-page-1/#comment-5757</link>
		<dc:creator>Bicho44</dc:creator>
		<pubDate>Mon, 18 May 2009 03:25:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.ninjapenguin.co.uk/blog/?p=38#comment-5757</guid>
		<description>Hi: i receive the same error like bumperbox, anyone have the solution?</description>
		<content:encoded><![CDATA[<p>Hi: i receive the same error like bumperbox, anyone have the solution?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bumperbox</title>
		<link>http://www.ninjapenguin.co.uk/blog/2008/09/25/kohana-orm-tip-orm-tree/comment-page-1/#comment-5627</link>
		<dc:creator>bumperbox</dc:creator>
		<pubDate>Sun, 26 Apr 2009 03:01:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.ninjapenguin.co.uk/blog/?p=38#comment-5627</guid>
		<description>i have tried a really simple example of this and can&#039;t get it working.

do i need to have a foreign key on the table ?

this is my table
catalogues
id 	 	 	
parent_id
name

my model file
class Catalogue_Model extends ORM_Tree {
 	protected $children = &quot;catalogues&quot;;
}

my code
$catalogues = ORM::factory(&#039;catalogue&#039;)-&gt;where(&#039;parent_id&#039;, $id)-&gt;find_all();		

foreach($catalogues as $cat) {
foreach ($cat-&gt;children as $subcat) {
do stuff
}

error message
Fatal error: Class &#039;_Model&#039; not found in \system\libraries\ORM.php on line 82</description>
		<content:encoded><![CDATA[<p>i have tried a really simple example of this and can&#8217;t get it working.</p>
<p>do i need to have a foreign key on the table ?</p>
<p>this is my table<br />
catalogues<br />
id<br />
parent_id<br />
name</p>
<p>my model file<br />
class Catalogue_Model extends ORM_Tree {<br />
 	protected $children = &#8220;catalogues&#8221;;<br />
}</p>
<p>my code<br />
$catalogues = ORM::factory(&#8216;catalogue&#8217;)-&gt;where(&#8216;parent_id&#8217;, $id)-&gt;find_all();		</p>
<p>foreach($catalogues as $cat) {<br />
foreach ($cat-&gt;children as $subcat) {<br />
do stuff<br />
}</p>
<p>error message<br />
Fatal error: Class &#8216;_Model&#8217; not found in \system\libraries\ORM.php on line 82</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dexter</title>
		<link>http://www.ninjapenguin.co.uk/blog/2008/09/25/kohana-orm-tip-orm-tree/comment-page-1/#comment-4419</link>
		<dc:creator>Dexter</dc:creator>
		<pubDate>Tue, 13 Jan 2009 13:20:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.ninjapenguin.co.uk/blog/?p=38#comment-4419</guid>
		<description>How can I add categories/subcategories in table &#039;categories&#039; using ORM or I need every time using SQL query like this:
INSERT INTO `categories` VALUES (1,&#039;root&#039;,0),(2,&#039;beer&#039;,1),(3,&#039;meat&#039;,1),(4,&#039;pork&#039;,3),(5,&#039;beef&#039;,3); ???</description>
		<content:encoded><![CDATA[<p>How can I add categories/subcategories in table &#8216;categories&#8217; using ORM or I need every time using SQL query like this:<br />
INSERT INTO `categories` VALUES (1,&#8217;root&#8217;,0),(2,&#8217;beer&#8217;,1),(3,&#8217;meat&#8217;,1),(4,&#8217;pork&#8217;,3),(5,&#8217;beef&#8217;,3); ???</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://www.ninjapenguin.co.uk/blog/2008/09/25/kohana-orm-tip-orm-tree/comment-page-1/#comment-2505</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Sat, 18 Oct 2008 09:32:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.ninjapenguin.co.uk/blog/?p=38#comment-2505</guid>
		<description>Hi jshaw,

I noticed shortly after your post here that Wouter helped you out with this over at the Kohana Forums, so hopefully you have managed to resolve this!

For others wanting to follow the resolution to this then check out the thread at &lt;a href=&quot;http://forum.kohanaphp.com/comments.php?DiscussionID=1423&quot; rel=&quot;nofollow&quot;&gt;the forums&lt;/a&gt;.

/Matt</description>
		<content:encoded><![CDATA[<p>Hi jshaw,</p>
<p>I noticed shortly after your post here that Wouter helped you out with this over at the Kohana Forums, so hopefully you have managed to resolve this!</p>
<p>For others wanting to follow the resolution to this then check out the thread at <a href="http://forum.kohanaphp.com/comments.php?DiscussionID=1423" rel="nofollow">the forums</a>.</p>
<p>/Matt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jshaw86</title>
		<link>http://www.ninjapenguin.co.uk/blog/2008/09/25/kohana-orm-tip-orm-tree/comment-page-1/#comment-2475</link>
		<dc:creator>jshaw86</dc:creator>
		<pubDate>Thu, 16 Oct 2008 21:29:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.ninjapenguin.co.uk/blog/?p=38#comment-2475</guid>
		<description>I&#039;ve been trying to get this to work for a couple hours now. I had a couple questions:
1) do we still need our pivot table relationship arrays(ie has_one, has_and_belongs_to_many).
2) I don&#039;t get the children thing, why is categories a child of Category.

My situtation is I have 3 entities:events,people,sororities, all are many-to-many relationships. So all entities are parents and children of eachother. Thanks.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve been trying to get this to work for a couple hours now. I had a couple questions:<br />
1) do we still need our pivot table relationship arrays(ie has_one, has_and_belongs_to_many).<br />
2) I don&#8217;t get the children thing, why is categories a child of Category.</p>
<p>My situtation is I have 3 entities:events,people,sororities, all are many-to-many relationships. So all entities are parents and children of eachother. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://www.ninjapenguin.co.uk/blog/2008/09/25/kohana-orm-tip-orm-tree/comment-page-1/#comment-2230</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Tue, 30 Sep 2008 21:45:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.ninjapenguin.co.uk/blog/?p=38#comment-2230</guid>
		<description>Thanks for the comments!

Zeelot - I&#039;ll try and get some more usage examples of this together for you, although the beauty of this is that it is a simple extension of the ORM library, so it inherits all the standard ORM features

Spirit - Off the top of my head you could always retreive the child and then recursively determine the parent until you encounter the root node

&lt;pre lang=&quot;php&quot;&gt;
  while(true)
  {
    if($node-&gt;parent == null) break;

    $crumbs[] = $node-&gt;parent;
    $node = $node-&gt;parent;
  }
&lt;/pre&gt;

**Note the above is sudo code, but that is the basic idea, just start with your node in question and loop through its parents until you hit root

Hope that helps!

/Matt</description>
		<content:encoded><![CDATA[<p>Thanks for the comments!</p>
<p>Zeelot &#8211; I&#8217;ll try and get some more usage examples of this together for you, although the beauty of this is that it is a simple extension of the ORM library, so it inherits all the standard ORM features</p>
<p>Spirit &#8211; Off the top of my head you could always retreive the child and then recursively determine the parent until you encounter the root node</p>
<pre lang="php">
  while(true)
  {
    if($node->parent == null) break;

    $crumbs[] = $node->parent;
    $node = $node->parent;
  }
</pre>
<p>**Note the above is sudo code, but that is the basic idea, just start with your node in question and loop through its parents until you hit root</p>
<p>Hope that helps!</p>
<p>/Matt</p>
]]></content:encoded>
	</item>
</channel>
</rss>

