HierarchicalTrait::getParent

@param int $idParent

@return bool|\O2System\Framework\Models\Sql\DataObjects\Result\Row
482511
public function getParent($idParent)
    {
        if ($parent = $this->qb
            ->select($this->table . '.*')
            ->from($this->table)
            ->where($this->primaryKey, $idParent)
            ->get(1)) {
            if ($parent->count() == 1) {
                return $parent->first();
            }
        }

        return false;
    }
987149
public function getParent()
    {
        return $this->owner
            ->hasOne($this->ownerClassName, [ $this->primaryKey => $this->parentIdField ])
            ->one();
    }
957791
public function getParentServer()
    {
      if ($this->_parentServer) return $this->_parentServer;
      
      $fields = self::getDbConnection()->fetchAssoc( 
          " SELECT C.*
    		    FROM dir_structure B, dir_structure A, dir_data C
    		    WHERE A.data_id=? and B.lft<=A.lft and B.rght>=A.lft and
    		    B.data_id=C.id and C.is_server<>0", 
          array( (int)$this->id )
      );
      
      if ($fields) {
          $this->_parentServer = Server::fetch($fields);
          return $this->_parentServer;
      }
      return FALSE;
    }
1267378
public function getParents($depth = null)
    {
        /** @var \yii\db\ActiveQuery|MaterializedPathQueryTrait $query */
        $query = $this->owner->find();
        return $query->parentsOf($this->owner, $depth);
    }
389941
public function getChildren($iId, $bRecursive = false, array $aData = [])
    {
        $aQueryData = $aData;
        if (!array_key_exists('where', $aQueryData)) {
            $aQueryData['where'] = [];
        }
        $aQueryData['where'][] = ['parent_id', $iId];

        $aChildren = $this->getAll($aQueryData);
        foreach ($aChildren as $oChild) {
            if ($bRecursive) {
                $oChild->children = $this->getChildren($oChild->id, $bRecursive, $aData);
            }
        }
        return $aChildren;
    }
1336516
public function getParents($withSelf = TRUE) {
    $node = $this;
    $parents = array();
    while ($node->getParent() != NULL) {
      $parents[] = $node->getParent();
      $node = $node->getParent();
    }
    if ($withSelf) array_unshift($parents,$this);
    return $parents;
  }
127651
public function topParent()
    {
        $topParent = $this->parent();

        if (!$topParent) {
            return null;
        }

        while (true) {
            $theParent = $topParent->parent();
            if ($theParent !== null && $theParent->parent() !== null) {
                $topParent = $theParent;
            } else {
                break;
            }
        }

        return $topParent;
    }
243514
public function rebuildTree($idParent = 0, $left = 1, $depth = 0)
    {
        ini_set('xdebug.max_nesting_level', 10000);
        ini_set('memory_limit', '-1');

        if ($childs = $this->qb
            ->table($this->table)
            ->select('id')
            ->where($this->parentKey, $idParent)
            ->orderBy('id')
            ->get()) {

            $right = $left + 1;

            $i = 0;
            foreach ($childs as $child) {
                if ($i == 0) {
                    $this->qb
                        ->from($this->table)
                        ->where('id', $child->id)
                        ->update($update = [
                            'record_left'  => $left,
                            'record_right' => $right,
                            'record_depth' => $depth,
                        ]);
                } else {
                    $this->qb
                        ->from($this->table)
                        ->where('id', $child->id)
                        ->update($update = [
                            'record_left'  => $left = $right + 1,
                            'record_right' => $right = $left + 1,
                            'record_depth' => $depth,
                        ]);
                }

                $update[ 'id' ] = $child->id;

                if ($this->qb
                    ->table($this->table)
                    ->select('id')
                    ->where($this->parentKey, $child->id)
                    ->orderBy('id')
                    ->get()) {
                    $right = $this->rebuildTree($child->id, $right, $depth + 1);
                    $this->qb
                        ->from($this->table)
                        ->where('id', $child->id)
                        ->update($update = [
                            'record_right' => $right,
                        ]);
                    $update[ 'id' ] = $child->id;
                }

                $i++;
            }
        }

        return $right + 1;
    }
161041
public function getListParent()
    {
        $parent = session()->get($this->getSessionKey(static::TYPE_PARENT));

        if (null === $parent) {
            return null;
        }

        if (static::PARENT_DISABLE === $parent) {
            return false;
        }

        list($relation, $key) = explode(':', $parent, 2);

        return compact('relation', 'key');
    }
754553
public function getParent()
    {
        $parentID = $this->getField("ParentID");
        if ($parentID) {
            return SiteTree::get_by_id(self::class, $parentID);
        }
        return null;
    }
1064238
public function getRootParent(MenuItemInterface $menuItem)
    {
        if (!$menuItem->getId()) {
            return false;
        }

        if ($parent = $menuItem->getParent()) {
            return $this->getRootParent($parent);
        }

        return $menuItem;
    }
1061406
protected function getParentsHierarchyField($dataObject) {
		
		// see if we've got Parent values
		if (is_object($dataObject) && method_exists($dataObject, 'hasField') && $dataObject->hasField('ParentID')) {
			$parentsField = array('Type' => '', 'Value' => null);
			$parents = array();
			
			$parent = $dataObject;
			while ($parent && $parent->ParentID) {
				$parents[] = $parent->ParentID;
				$parent = $parent->Parent();
				// fix for odd behaviour - in some instance a node is being assigned as its own parent. 
				if ($parent->ParentID == $parent->ID) {
					$parent = null;
				}
			}
			$parentsField['Value'] = $parents;
			return $parentsField;
		}
	}
1240476
public function getParent()
    {
        $depth = $this->iterator->getDepth();

        return $depth === 0
            ? $this->id
            : $this->iterator->getSubIterator($depth - 1)->key();
    }
437214
public function getParentRepository()
    {
        if (null == $this->parentRepository) {
            $this->setParentRepository(
                Orm::getRepository($this->getParentEntity())
            );
        }
        return $this->parentRepository;
    }
844203
public function findParentNodesByChildId($id)
	{
        // To be returned
        $result = array();

        $rl = $this->getRelations();
        $data = $rl[RelationBuilder::TREE_PARAM_ITEMS];

        // If can't find, then return empty array
        if (!isset($data[$id])) {
            return array();
        }

        $current = $data[$id];
        $parentId = $current[RelationBuilder::TREE_PARAM_PARENT_ID];

        while (isset($data[$parentId])) {
            $current = $data[$parentId];
            $parentId = $current[RelationBuilder::TREE_PARAM_PARENT_ID];

            array_push($result, $current);
        }

        return $result;
    }
352127
public function getParent()
    {
        if ($this->parent === null) {
            $this->setParent($this->groupParameterRepository->getByChild($this));
        }
        return $this->parent;
    }
240343
public function getNumOfParent($id)
    {
        if ($parents = $this->qb
            ->table($this->table)
            ->select('id')
            ->where('id', $id)
            ->get()) {
            return $parents->count();
        }

        return 0;
    }