TreeBehavior::parentIds PHP Method

parentIds() public method

get immediate parent ids for the object (note there may be more than one because any disorder can exist in more than one tree).
public parentIds ( )
    public function parentIds()
    {
        $owner = $this->getOwner();
        $db = $owner->getDbConnection();
        $query = 'SELECT ' . $this->idAttribute . ' as owner, (' . 'SELECT id FROM ' . $owner->treeTable() . ' AS t2 ' . 'WHERE t2.' . $this->leftAttribute . ' < t1.' . $this->leftAttribute . ' AND t2.' . $this->rightAttribute . ' > t1.' . $this->rightAttribute . ' ORDER BY t2.' . $this->rightAttribute . ' - t1.' . $this->rightAttribute . ' ASC LIMIT 1)' . ' AS parent' . ' FROM ' . $owner->treeTable() . ' AS t1' . ' WHERE t1.' . $this->idAttribute . ' = ' . $db->quoteValue($owner->id);
        $res = $db->createCommand($query)->query();
        $ids = array();
        foreach ($res as $r) {
            if ($r['parent'] != null) {
                $ids[] = $r['parent'];
            }
        }
        return $ids;
    }