Postgres::alterDomain PHP Method

alterDomain() public method

Alters a domain
public alterDomain ( $domain, $domdefault, $domnotnull, $domowner ) : -4
$domain The domain to alter
$domdefault The domain default
$domnotnull True for NOT NULL, false otherwise
$domowner The domain owner
return -4
    function alterDomain($domain, $domdefault, $domnotnull, $domowner)
    {
        $f_schema = $this->_schema;
        $this->fieldClean($f_schema);
        $this->fieldClean($domain);
        $this->fieldClean($domowner);
        $status = $this->beginTransaction();
        if ($status != 0) {
            $this->rollbackTransaction();
            return -1;
        }
        // Default
        if ($domdefault == '') {
            $sql = "ALTER DOMAIN \"{$f_schema}\".\"{$domain}\" DROP DEFAULT";
        } else {
            $sql = "ALTER DOMAIN \"{$f_schema}\".\"{$domain}\" SET DEFAULT {$domdefault}";
        }
        $status = $this->execute($sql);
        if ($status != 0) {
            $this->rollbackTransaction();
            return -2;
        }
        // NOT NULL
        if ($domnotnull) {
            $sql = "ALTER DOMAIN \"{$f_schema}\".\"{$domain}\" SET NOT NULL";
        } else {
            $sql = "ALTER DOMAIN \"{$f_schema}\".\"{$domain}\" DROP NOT NULL";
        }
        $status = $this->execute($sql);
        if ($status != 0) {
            $this->rollbackTransaction();
            return -3;
        }
        // Owner
        $sql = "ALTER DOMAIN \"{$f_schema}\".\"{$domain}\" OWNER TO \"{$domowner}\"";
        $status = $this->execute($sql);
        if ($status != 0) {
            $this->rollbackTransaction();
            return -4;
        }
        return $this->endTransaction();
    }
Postgres