Postgres::addPrimaryKey PHP Метод

addPrimaryKey() публичный Метод

Adds a primary key constraint to a table
public addPrimaryKey ( $table, $fields, $name = '', $tablespace = '' ) : -1
$table The table to which to add the primery key
$fields (array) An array of fields over which to add the primary key
$name (optional) The name to give the key, otherwise default name is assigned
$tablespace (optional) The tablespace for the schema, '' indicates default.
Результат -1
    function addPrimaryKey($table, $fields, $name = '', $tablespace = '')
    {
        if (!is_array($fields) || sizeof($fields) == 0) {
            return -1;
        }
        $f_schema = $this->_schema;
        $this->fieldClean($f_schema);
        $this->fieldClean($table);
        $this->fieldArrayClean($fields);
        $this->fieldClean($name);
        $this->fieldClean($tablespace);
        $sql = "ALTER TABLE \"{$f_schema}\".\"{$table}\" ADD ";
        if ($name != '') {
            $sql .= "CONSTRAINT \"{$name}\" ";
        }
        $sql .= "PRIMARY KEY (\"" . join('","', $fields) . "\")";
        if ($tablespace != '' && $this->hasTablespaces()) {
            $sql .= " USING INDEX TABLESPACE \"{$tablespace}\"";
        }
        return $this->execute($sql);
    }
Postgres