public function Schema::fieldExists in Drupal driver for SQL Server and SQL Azure 4.2.x
Same name and namespace in other branches
- 3.1.x src/Driver/Database/sqlsrv/Schema.php \Drupal\sqlsrv\Driver\Database\sqlsrv\Schema::fieldExists()
- 4.0.x src/Driver/Database/sqlsrv/Schema.php \Drupal\sqlsrv\Driver\Database\sqlsrv\Schema::fieldExists()
- 4.1.x src/Driver/Database/sqlsrv/Schema.php \Drupal\sqlsrv\Driver\Database\sqlsrv\Schema::fieldExists()
Check if a column exists in the given table.
Parameters
string $table: The name of the table in drupal (no prefixing).
string $column: The name of the column.
Return value
TRUE if the given column exists, otherwise FALSE.
Overrides Schema::fieldExists
5 calls to Schema::fieldExists()
- Schema::addField in src/
Driver/ Database/ sqlsrv/ Schema.php - Add a new field to a table.
- Schema::changeField in src/
Driver/ Database/ sqlsrv/ Schema.php - Change a field definition.
- Schema::cleanUpPrimaryKey in src/
Driver/ Database/ sqlsrv/ Schema.php - Drop the primary key constraint.
- Schema::createTechnicalPrimaryColumn in src/
Driver/ Database/ sqlsrv/ Schema.php - Add a primary column to the table.
- Schema::dropField in src/
Driver/ Database/ sqlsrv/ Schema.php - Should this be in a Transaction?
File
- src/
Driver/ Database/ sqlsrv/ Schema.php, line 229
Class
Namespace
Drupal\sqlsrv\Driver\Database\sqlsrvCode
public function fieldExists($table, $field) {
$prefixInfo = $this
->getPrefixInfo($table, TRUE);
return $this->connection
->queryDirect('SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = :table AND column_name = :name', [
':table' => $prefixInfo['table'],
':name' => $field,
])
->fetchField() !== FALSE;
}