git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6249 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-12-25 07:59:13 +00:00
parent b96a3a2e6f
commit 9c6f44006f

View file

@ -1760,20 +1760,21 @@ class Model extends Overloadable {
*
* @param array $data Results of find operation
* @param string $root NULL or id for root node of operation
* @param integer $index last processed index of $data
* @return array Threaded results
* @access private
* @see Model::findAllThreaded()
*/
function __doThread($data, $root) {
function __doThread($data, $root, $index = 0) {
$out = array();
$sizeOf = sizeof($data);
for ($ii = 0; $ii < $sizeOf; $ii++) {
for ($ii = $index; $ii < $sizeOf; $ii++) {
if (($data[$ii][$this->alias]['parent_id'] == $root) || (($root === null) && ($data[$ii][$this->alias]['parent_id'] == '0'))) {
$tmp = $data[$ii];
if (isset($data[$ii][$this->alias][$this->primaryKey])) {
$tmp['children'] = $this->__doThread($data, $data[$ii][$this->alias][$this->primaryKey]);
$tmp['children'] = $this->__doThread($data, $data[$ii][$this->alias][$this->primaryKey], $ii);
} else {
$tmp['children'] = null;
}