public function getPath($pk = null, $allFields = false)
    {
        $k = $this->getKeyName();
        $pk = $pk === null ? $this->$k : $pk;

        // Get the path from the node to the root.
        $query = $this->db->getQuery(true)
            ->select('p.' . $k . ', p.parent_id, p.level, p.lft, p.rgt')
            ->from($this->db->quoteName($this->table) . ' AS n, ' . $this->db->quoteName($this->table) . ' AS p')
            ->where('n.lft BETWEEN p.lft AND p.rgt')
            ->where('n.' . $k . ' = ' . (int) $pk)
            ->order('p.lft');

        if ($allFields) {
            $query->select('p.*');
        }

        return $this->db->getReader($query)->loadObjectList();
    }
public function getPath($pk = null, $allFields = false)
    {
        $k = $this->getKeyName();
        $pk = $pk === null ? $this->$k : $pk;

        // Get the path from the node to the root.
        $query = $this->db->getQuery(true)
            ->select('p.' . $k . ', p.parent_id, p.level, p.lft, p.rgt')
            ->from($this->db->quoteName($this->table) . ' AS n, ' . $this->db->quoteName($this->table) . ' AS p')
            ->where('n.lft BETWEEN p.lft AND p.rgt')
            ->where('n.' . $k . ' = ' . (int) $pk)
            ->order('p.lft');

        if ($allFields) {
            $query->select('p.*');
        }

        return $this->db->getReader($query)->loadObjectList();
    }
public function getPath ( $ pk = null , $ allFields = false ) { $ k = $ this -> getKeyName ( ) ; $ pk = $ pk === null ? $ this -> $ k : $ pk ; // Get the path from the node to the root. $ query = $ this -> db -> getQuery ( true ) -> select ( 'p.' . $ k . ', p.parent_id, p.level, p.lft, p.rgt' ) -> from ( $ this -> db -> quoteName ( $ this -> table ) . ' AS n, ' . $ this -> db -> quoteName ( $ this -> table ) . ' AS p' ) -> where ( 'n.lft BETWEEN p.lft AND p.rgt' ) -> where ( 'n.' . $ k . ' = ' . ( int ) $ pk ) -> order ( 'p.lft' ) ; if ( $ allFields ) { $ query -> select ( 'p.*' ) ; } return $ this -> db -> getReader ( $ query ) -> loadObjectList ( ) ; }
Method to get an array of nodes from a given node to its root.

@param   integer $pk        Primary key of the node for which to get the path.
@param   boolean $allFields Get all fields.

@return mixed An array of node objects including the start node.

@since   2.0
Method to get an array of nodes from a given node to its root .