Postgres::getConstraints PHP Method

getConstraints() public method

Returns a list of all constraints on a table
public getConstraints ( $table ) : A
$table The table to find rules for
return A recordset
    function getConstraints($table)
    {
        $c_schema = $this->_schema;
        $this->clean($c_schema);
        $this->clean($table);
        // This SQL is greatly complicated by the need to retrieve
        // index clustering information for primary and unique constraints
        $sql = "SELECT\n\t\t\t\tpc.conname,\n\t\t\t\tpg_catalog.pg_get_constraintdef(pc.oid, true) AS consrc,\n\t\t\t\tpc.contype,\n\t\t\t\tCASE WHEN pc.contype='u' OR pc.contype='p' THEN (\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tindisclustered\n\t\t\t\t\tFROM\n\t\t\t\t\t\tpg_catalog.pg_depend pd,\n\t\t\t\t\t\tpg_catalog.pg_class pl,\n\t\t\t\t\t\tpg_catalog.pg_index pi\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tpd.refclassid=pc.tableoid\n\t\t\t\t\t\tAND pd.refobjid=pc.oid\n\t\t\t\t\t\tAND pd.objid=pl.oid\n\t\t\t\t\t\tAND pl.oid=pi.indexrelid\n\t\t\t\t) ELSE\n\t\t\t\t\tNULL\n\t\t\t\tEND AS indisclustered\n\t\t\tFROM\n\t\t\t\tpg_catalog.pg_constraint pc\n\t\t\tWHERE\n\t\t\t\tpc.conrelid = (SELECT oid FROM pg_catalog.pg_class WHERE relname='{$table}'\n\t\t\t\t\tAND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace\n\t\t\t\t\tWHERE nspname='{$c_schema}'))\n\t\t\tORDER BY\n\t\t\t\t1\n\t\t";
        return $this->selectSet($sql);
    }
Postgres