You are here

public function Scheme::ConstraintExists in Drupal driver for SQL Server and SQL Azure 8.2

Check if a constraint exists.

Parameters

string $table:

ConstraintTypes $type:

Return value

bool

File

drivers/lib/Drupal/Driver/Database/sqlsrv/Scheme.php, line 79

Class

Scheme

Namespace

Drupal\Driver\Database\sqlsrv

Code

public function ConstraintExists($name, ConstraintTypes $type) {
  return (bool) $this->cnn
    ->query_execute("SELECT CASE WHEN OBJECT_ID(:name, :type) IS NULL THEN 0 ELSE 1 END", array(
    ':type' => $type
      ->__toString(),
    ':name' => "dbo.[{$name}]",
  ))
    ->fetchField();
}