protected function getNode($id, $key = null)
    {
        // Determine which key to get the node base on.
        switch ($key) {
            case 'parent':
                $k = 'parent_id';
                break;

            case 'left':
                $k = 'lft';
                break;

            case 'right':
                $k = 'rgt';
                break;

            default:
                $k = $this->getKeyName();
                break;
        }

        // Get the node data.
        $query = $this->db->getQuery(true)
            ->select($this->getKeyName() . ', parent_id, level, lft, rgt')
            ->from($this->db->quoteName($this->table))
            ->where($k . ' = ' . $id)
            ->limit(1);

        $row = $this->db->getReader($query)->loadObject();

        // Check for no $row returned
        if (empty($row)) {
            throw new NestedHandleException(sprintf('%s::getNode(%d, %s) failed.', get_class($this), $id, $key));
        }

        // Do some simple calculations.
        $row->numChildren = (int) ($row->rgt - $row->lft - 1) / 2;
        $row->width = (int) $row->rgt - $row->lft + 1;

        return $row;
    }
protected function getNode($id, $key = null)
    {
        // Determine which key to get the node base on.
        switch ($key) {
            case 'parent':
                $k = 'parent_id';
                break;

            case 'left':
                $k = 'lft';
                break;

            case 'right':
                $k = 'rgt';
                break;

            default:
                $k = $this->getKeyName();
                break;
        }

        // Get the node data.
        $query = $this->db->getQuery(true)
            ->select($this->getKeyName() . ', parent_id, level, lft, rgt')
            ->from($this->db->quoteName($this->table))
            ->where($k . ' = ' . $id)
            ->limit(1);

        $row = $this->db->getReader($query)->loadObject();

        // Check for no $row returned
        if (empty($row)) {
            throw new NestedHandleException(sprintf('%s::getNode(%d, %s) failed.', get_class($this), $id, $key));
        }

        // Do some simple calculations.
        $row->numChildren = (int) ($row->rgt - $row->lft - 1) / 2;
        $row->width = (int) $row->rgt - $row->lft + 1;

        return $row;
    }
protected function getNode ( $ id , $ key = null ) { // Determine which key to get the node base on. switch ( $ key ) { case 'parent' : $ k = 'parent_id' ; break ; case 'left' : $ k = 'lft' ; break ; case 'right' : $ k = 'rgt' ; break ; default : $ k = $ this -> getKeyName ( ) ; break ; } // Get the node data. $ query = $ this -> db -> getQuery ( true ) -> select ( $ this -> getKeyName ( ) . ', parent_id, level, lft, rgt' ) -> from ( $ this -> db -> quoteName ( $ this -> table ) ) -> where ( $ k . ' = ' . $ id ) -> limit ( 1 ) ; $ row = $ this -> db -> getReader ( $ query ) -> loadObject ( ) ; // Check for no $row returned if ( empty ( $ row ) ) { throw new NestedHandleException ( sprintf ( '%s::getNode(%d, %s) failed.' , get_class ( $ this ) , $ id , $ key ) ) ; } // Do some simple calculations. $ row -> numChildren = ( int ) ( $ row -> rgt - $ row -> lft - 1 ) / 2 ; $ row -> width = ( int ) $ row -> rgt - $ row -> lft + 1 ; return $ row ; }
Method to get nested set properties for a node in the tree.

@param   integer $id    Value to look up the node by.
@param   string  $key   An optional key to look up the node by (parent | left | right).
If omitted, the primary key of the table is used.

@return  mixed    Boolean false on failure or node object on success.

@since   2.0
@throws  \RuntimeException on database error.
Method to get nested set properties for a node in the tree .