public function loadParents() { if (is_array($this->values)) { $fieldNames = array_keys($this->values); $selectedFields = array(); foreach ($fieldNames as $name) { $selectedFields[] = 'node.' . $name; } $query = "\n SELECT\n " . implode(',', $selectedFields) . "\n FROM " . static::getTableName() . " root\n JOIN " . static::getTableName() . " node\n ON root." . $this->getLeftBoundFieldName() . ">node." . $this->getLeftBoundFieldName() . "\n AND root." . $this->getRightBoundFieldName() . "<node." . $this->getRightBoundFieldName() . "\n WHERE root." . $this->getPrimaryKeyFieldName() . "=" . $this->values[$this->getPrimaryKeyFieldName()] . "\n ORDER BY " . $this->getLeftBoundFieldName() . " DESC\n "; $rows = $this->queryAndFetch($query); foreach ($rows as $values) { $node = new Static($this->getSource()); $node->setValues($values); $this->parents[] = $node; } } return $this; }