public function Schema::fieldExists in Drupal driver for SQL Server and SQL Azure 3.0.x
Same name and namespace in other branches
- 8.2 drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php \Drupal\Driver\Database\sqlsrv\Schema::fieldExists()
- 8 drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php \Drupal\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
7 calls to Schema::fieldExists()
- Schema::addField in drivers/lib/ Drupal/ Driver/ Database/ sqlsrv/ Schema.php 
- Add a new field to a table.
- Schema::changeField in drivers/lib/ Drupal/ Driver/ Database/ sqlsrv/ Schema.php 
- Change a field definition.
- Schema::cleanUpPrimaryKey in drivers/lib/ Drupal/ Driver/ Database/ sqlsrv/ Schema.php 
- Drop the primary key constraint.
- Schema::createTechnicalPrimaryColumn in drivers/lib/ Drupal/ Driver/ Database/ sqlsrv/ Schema.php 
- Add a primary column to the table.
- Schema::dropField in drivers/lib/ Drupal/ Driver/ Database/ sqlsrv/ Schema.php 
- Should this be in a Transaction?
File
- drivers/lib/ Drupal/ Driver/ Database/ sqlsrv/ Schema.php, line 229 
Class
Namespace
Drupal\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;
}