Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

warning about parent_id requirement for threaded find #405

Merged
merged 1 commit into from

2 participants

@dereuromark
Collaborator

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
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.