public function setDatabase(MDB2_Driver_Common $db, array $set = array())
    {
        $key = spl_object_hash($this);

        if (isset($set[$key])) {
            // prevent infinite recursion on datastructure cycles
            return;
        }

        $this->db = $db;
        $set[$key] = true;

        foreach ($this->objects as $object) {
            if ($object instanceof SwatDBRecordable) {
                $object->setDatabase($db, $set);
            }
        }
    }