Skip to content

Commit

Permalink
Merge pull request #405 from dereuromark/threaded
Browse files Browse the repository at this point in the history
warning about parent_id requirement for threaded find
  • Loading branch information
lorenzo committed Oct 10, 2012
2 parents 5896d03 + 3191517 commit a02a476
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion en/models/retrieving-your-data.rst
Expand Up @@ -293,7 +293,7 @@ model data to build nested results. Below are a couple of simple
public function some_function() { public function some_function() {
// ... // ...
$allCategories = $this->Category->find('threaded'); $allCategories = $this->Category->find('threaded');
$someCategories = $this->Comment->find('threaded', array( $comments = $this->Comment->find('threaded', array(
'conditions' => array('article_id' => 50) 'conditions' => array('article_id' => 50)
)); ));
// ... // ...
Expand Down Expand Up @@ -366,6 +366,19 @@ appear in name order. Likewise any order can be used, there is no
inbuilt requirement of this method for the top result to be inbuilt requirement of this method for the top result to be
returned first. returned first.


.. warning::

If you specify ``fields``, you need to always include the parent_id (or its current alias):

<?php
public function some_function() {
$categories = $this->Category->find('threaded', array(
'fields' => array('id', 'name', 'parent_id')
));
}

Otherwise the returned array will not be of the expected nested structure from above.

.. _model-find-neighbors: .. _model-find-neighbors:


find('neighbors') find('neighbors')
Expand Down

0 comments on commit a02a476

Please sign in to comment.