protected function DatabaseSchema_pgsql::constraintExists

protected DatabaseSchema_pgsql::constraintExists($table, $name)

Helper function: check if a constraint (PK, FK, UK) exists.

Parameters

$table: The name of the table.

$name: The name of the constraint (typically 'pkey' or '[constraint]_key').

File

includes/database/pgsql/schema.inc, line 431
Database schema code for PostgreSQL database servers.

Class

DatabaseSchema_pgsql

Code

protected function constraintExists($table, $name) {
  $constraint_name = '{' . $table . '}_' . $name;
  return (bool) $this->connection->query("SELECT 1 FROM pg_constraint WHERE conname = '$constraint_name'")->fetchField();
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!database!pgsql!schema.inc/function/DatabaseSchema_pgsql::constraintExists/7.x