Skip to content

Loading…

warning about parent_id requirement for threaded find #405

Merged
merged 1 commit into from

2 participants

@dereuromark
CakePHP member

as replacement and agreed outcome of cakephp/cakephp#893

@lorenzo lorenzo merged commit a02a476 into cakephp:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 10, 2012
  1. @dereuromark
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 1 deletion.
  1. +14 −1 en/models/retrieving-your-data.rst
View
15 en/models/retrieving-your-data.rst
@@ -293,7 +293,7 @@ model data to build nested results. Below are a couple of simple
public function some_function() {
// ...
$allCategories = $this->Category->find('threaded');
- $someCategories = $this->Comment->find('threaded', array(
+ $comments = $this->Comment->find('threaded', array(
'conditions' => array('article_id' => 50)
));
// ...
@@ -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
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:
find('neighbors')
Something went wrong with that request. Please try again.