mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-03 10:02:42 +00:00
parent
d238d8c0bb
commit
a8bc916104
1 changed files with 8 additions and 7 deletions
|
@ -2815,16 +2815,17 @@ class Model extends Object implements CakeEventListener {
|
||||||
$return = $idMap = array();
|
$return = $idMap = array();
|
||||||
$ids = Set::extract($results, '{n}.' . $this->alias . '.' . $this->primaryKey);
|
$ids = Set::extract($results, '{n}.' . $this->alias . '.' . $this->primaryKey);
|
||||||
|
|
||||||
|
if (isset($results[0][$this->alias]) && !array_key_exists('parent_id', $results[0][$this->alias])) {
|
||||||
|
trigger_error(
|
||||||
|
__d('cake_dev', 'You cannot use find("threaded") on models without a "parent_id" field.'),
|
||||||
|
E_USER_WARNING
|
||||||
|
);
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($results as $result) {
|
foreach ($results as $result) {
|
||||||
$result['children'] = array();
|
$result['children'] = array();
|
||||||
$id = $result[$this->alias][$this->primaryKey];
|
$id = $result[$this->alias][$this->primaryKey];
|
||||||
if (!isset($result[$this->alias]['parent_id'])) {
|
|
||||||
trigger_error(
|
|
||||||
__d('cake_dev', 'You cannot use find("threaded") on models without a "parent_id" field.'),
|
|
||||||
E_USER_WARNING
|
|
||||||
);
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
$parentId = $result[$this->alias]['parent_id'];
|
$parentId = $result[$this->alias]['parent_id'];
|
||||||
if (isset($idMap[$id]['children'])) {
|
if (isset($idMap[$id]['children'])) {
|
||||||
$idMap[$id] = array_merge($result, (array)$idMap[$id]);
|
$idMap[$id] = array_merge($result, (array)$idMap[$id]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue