public function Schema::tableExists in Drupal driver for SQL Server and SQL Azure 8
Same name and namespace in other branches
- 8.2 drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php \Drupal\Driver\Database\sqlsrv\Schema::tableExists()
- 3.0.x drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php \Drupal\Driver\Database\sqlsrv\Schema::tableExists()
Find if a table already exists.
Parameters
$table: Name of the table.
Return value
True if the table exists, false otherwise.
Overrides Schema::tableExists
8 calls to Schema::tableExists()
- Schema::addField in drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Schema.php - Override DatabaseSchema::addField().
- Schema::addIndex in drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Schema.php - Override DatabaseSchema::addIndex().
- Schema::addPrimaryKey in drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Schema.php - Override DatabaseSchema::addPrimaryKey().
- Schema::addUniqueKey in drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Schema.php - Override DatabaseSchema::addUniqueKey().
- Schema::createTable in drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Schema.php - {@Inheritdoc}
File
- drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Schema.php, line 374 - Definition of Drupal\Driver\Database\sqlsrv\Schema
Class
Namespace
Drupal\Driver\Database\sqlsrvCode
public function tableExists($table) {
// If $table is NULL, then $table[0] will generate a notice.
if (empty($table)) {
return FALSE;
}
// Temporary tables and regular tables cannot be verified in the same way.
$query = NULL;
if ($table[0] == '#') {
$query = "SELECT 1 FROM tempdb.sys.tables WHERE name like '" . $this->connection
->prefixTables('{' . $table . '}') . "%'";
}
else {
$query = "SELECT 1 FROM INFORMATION_SCHEMA.tables WHERE table_name = '" . $this->connection
->prefixTables('{' . $table . '}') . "'";
}
$exists = $this->connection
->query_direct($query)
->fetchField() !== FALSE;
return $exists;
}