You are here

public function DatabaseSchema_sqlsrv::fieldExists in Drupal driver for SQL Server and SQL Azure 7.2

Same name and namespace in other branches
  1. 7.3 sqlsrv/schema.inc \DatabaseSchema_sqlsrv::fieldExists()
  2. 7 sqlsrv/schema.inc \DatabaseSchema_sqlsrv::fieldExists()

Check if a column exists in the given table.

Parameters

$table: The name of the table in drupal (no prefixing).

$name: The name of the column.

Return value

TRUE if the given column exists, otherwise FALSE.

Overrides DatabaseSchema::fieldExists

7 calls to DatabaseSchema_sqlsrv::fieldExists()
DatabaseSchema_sqlsrv::addField in sqlsrv/schema.inc
Override DatabaseSchema::addField().
DatabaseSchema_sqlsrv::changeField in sqlsrv/schema.inc
Override DatabaseSchema::changeField().
DatabaseSchema_sqlsrv::cleanUpPrimaryKey in sqlsrv/schema.inc
Drop the primary key constraint.
DatabaseSchema_sqlsrv::createTechnicalPrimaryColumn in sqlsrv/schema.inc
Add a primary column to the table.
DatabaseSchema_sqlsrv::dropField in sqlsrv/schema.inc
Override DatabaseSchema::dropField().

... See full list

File

sqlsrv/schema.inc, line 984
Database schema code for Microsoft SQL Server database servers.

Class

DatabaseSchema_sqlsrv

Code

public function fieldExists($table, $field) {
  return $this->connection
    ->query_direct("SELECT 1 FROM INFORMATION_SCHEMA.columns WHERE table_name = '" . $this->connection
    ->prefixTables('{' . $table . '}') . "' AND column_name = '" . $field . "'")
    ->fetchField() !== FALSE;
}