public function Schema::tableExists in Drupal driver for SQL Server and SQL Azure 4.0.x
Same name and namespace in other branches
- 4.2.x src/Driver/Database/sqlsrv/Schema.php \Drupal\sqlsrv\Driver\Database\sqlsrv\Schema::tableExists()
- 3.1.x src/Driver/Database/sqlsrv/Schema.php \Drupal\sqlsrv\Driver\Database\sqlsrv\Schema::tableExists()
- 4.1.x src/Driver/Database/sqlsrv/Schema.php \Drupal\sqlsrv\Driver\Database\sqlsrv\Schema::tableExists()
Temporary tables and regular tables cannot be verified in the same way.
Overrides Schema::tableExists
10 calls to Schema::tableExists()
- Schema::addField in src/
Driver/ Database/ sqlsrv/ Schema.php - Add a new field to a table.
- Schema::addIndex in src/
Driver/ Database/ sqlsrv/ Schema.php - Add an index.
- Schema::addPrimaryKey in src/
Driver/ Database/ sqlsrv/ Schema.php - Add a primary key.
- Schema::addUniqueKey in src/
Driver/ Database/ sqlsrv/ Schema.php - Add a unique key.
- Schema::createTable in src/
Driver/ Database/ sqlsrv/ Schema.php - Create a new table from a Drupal table definition.
File
- src/
Driver/ Database/ sqlsrv/ Schema.php, line 740
Class
Namespace
Drupal\sqlsrv\Driver\Database\sqlsrvCode
public function tableExists($table) {
if (empty($table)) {
return FALSE;
}
// Temporary tables and regular tables cannot be verified in the same way.
$query = NULL;
$prefixInfo = $this
->getPrefixInfo($table, TRUE);
$args = [];
if ($this->connection
->isTemporaryTable($table)) {
$query = "SELECT 1 FROM tempdb.sys.tables WHERE [object_id] = OBJECT_ID(:table)";
$args = [
':table' => 'tempdb.[' . $this
->getDefaultSchema() . '].[' . $prefixInfo['table'] . ']',
];
}
else {
$query = "SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE [table_name] = :table";
$args = [
':table' => $prefixInfo['table'],
];
}
return (bool) $this->connection
->queryDirect($query, $args)
->fetchField();
}