Postgres::dropCheckConstraint PHP Method

dropCheckConstraint() public method

Drops a check constraint from a table
public dropCheckConstraint ( $table, $name ) : -4
$table The table from which to drop the check
$name The name of the check to be dropped
return -4
    function dropCheckConstraint($table, $name)
    {
        $f_schema = $this->_schema;
        $this->fieldClean($f_schema);
        $c_schema = $this->_schema;
        $this->clean($c_schema);
        $c_table = $table;
        $this->fieldClean($table);
        $this->clean($c_table);
        $this->clean($name);
        // Begin transaction
        $status = $this->beginTransaction();
        if ($status != 0) {
            return -2;
        }
        // Properly lock the table
        $sql = "LOCK TABLE \"{$f_schema}\".\"{$table}\" IN ACCESS EXCLUSIVE MODE";
        $status = $this->execute($sql);
        if ($status != 0) {
            $this->rollbackTransaction();
            return -3;
        }
        // Delete the check constraint
        $sql = "DELETE FROM pg_relcheck WHERE rcrelid=(SELECT oid FROM pg_catalog.pg_class WHERE relname='{$c_table}'\n\t\t\tAND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE\n\t\t\tnspname = '{$c_schema}')) AND rcname='{$name}'";
        $status = $this->execute($sql);
        if ($status != 0) {
            $this->rollbackTransaction();
            return -4;
        }
        // Update the pg_class catalog to reflect the new number of checks
        $sql = "UPDATE pg_class SET relchecks=(SELECT COUNT(*) FROM pg_relcheck WHERE\n\t\t\t\t\trcrelid=(SELECT oid FROM pg_catalog.pg_class WHERE relname='{$c_table}'\n\t\t\t\t\t\tAND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE\n\t\t\t\t\t\tnspname = '{$c_schema}')))\n\t\t\t\t\tWHERE relname='{$c_table}'";
        $status = $this->execute($sql);
        if ($status != 0) {
            $this->rollbackTransaction();
            return -4;
        }
        // Otherwise, close the transaction
        return $this->endTransaction();
    }
Postgres