public function Schema::dropField 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::dropField()
- 3.1.x src/Driver/Database/sqlsrv/Schema.php \Drupal\sqlsrv\Driver\Database\sqlsrv\Schema::dropField()
- 4.1.x src/Driver/Database/sqlsrv/Schema.php \Drupal\sqlsrv\Driver\Database\sqlsrv\Schema::dropField()
Should this be in a Transaction?
Overrides Schema::dropField
3 calls to Schema::dropField()
- 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::cleanUpTechnicalPrimaryColumn in src/
Driver/ Database/ sqlsrv/ Schema.php - Tries to clean up the technical primary column.
File
- src/
Driver/ Database/ sqlsrv/ Schema.php, line 335
Class
Namespace
Drupal\sqlsrv\Driver\Database\sqlsrvCode
public function dropField($table, $field) {
if (!$this
->fieldExists($table, $field)) {
return FALSE;
}
$primary_key_fields = $this
->findPrimaryKeyColumns($table);
if (in_array($field, $primary_key_fields)) {
// Let's drop the PK.
$this
->cleanUpPrimaryKey($table);
$this
->createTechnicalPrimaryColumn($table);
}
// Drop the related objects.
$this
->dropFieldRelatedObjects($table, $field);
// Drop field comments.
if ($this
->getComment($table, $field) !== FALSE) {
$this->connection
->queryDirect($this
->deleteCommentSql($table, $field));
}
$this->connection
->query('ALTER TABLE {' . $table . '} DROP COLUMN ' . $field);
$this
->resetColumnInformation($table);
return TRUE;
}