public function assignRecord(array $record, DB $database)
    {
        $dao = $this->getDAO();
        $table = $dao->getTable($database);
        $pkey = $table->getPrimaryColumns();
        if ($pkey !== null)
        {
            $this->_id = array();
            foreach ($pkey as $col)
                $this->_id[$col->getName()] = $record[$col->getName()];
        }
        else
            $this->_id = null;

        $this->_record = $record;
        $this->_changed = array();
        $this->setSourceDB($database);
        $this->init();

        $columns = $table->getColumns($database);
        foreach ($columns as $name => $def)
        {
            if (!array_key_exists($name, $this->_record))
                continue;

            $this->_record[$name] = $def->afterFetchFilter($this->_record[$name]);
            
            // Synchronize local variables
            if (property_exists($this, $name))
                $this->$name = $this->_record[$name];
        }
        return $this;
    }