return $field;
}
+ /**
+ * {@inheritdoc}
+ */
public function getFieldTypeMap() {
// Put :normal last so it gets preserved by array_flip. This makes
// it much easier for modules (such as schema.module) to map
return implode(', ', $return);
}
+ /**
+ * {@inheritdoc}
+ */
public function renameTable($table, $new_name) {
if (!$this->tableExists($table)) {
throw new SchemaObjectDoesNotExistException(t("Cannot rename @table to @table_new: table @table doesn't exist.", ['@table' => $table, '@table_new' => $new_name]));
return $this->connection->query('ALTER TABLE {' . $table . '} RENAME TO `' . $info['table'] . '`');
}
+ /**
+ * {@inheritdoc}
+ */
public function dropTable($table) {
if (!$this->tableExists($table)) {
return FALSE;
return TRUE;
}
+ /**
+ * {@inheritdoc}
+ */
public function addField($table, $field, $spec, $keys_new = []) {
if (!$this->tableExists($table)) {
throw new SchemaObjectDoesNotExistException(t("Cannot add field @table.@field: table doesn't exist.", ['@field' => $field, '@table' => $table]));
}
}
+ /**
+ * {@inheritdoc}
+ */
public function dropField($table, $field) {
if (!$this->fieldExists($table, $field)) {
return FALSE;
return TRUE;
}
+ /**
+ * {@inheritdoc}
+ */
public function fieldSetDefault($table, $field, $default) {
if (!$this->fieldExists($table, $field)) {
throw new SchemaObjectDoesNotExistException(t("Cannot set default value of field @table.@field: field doesn't exist.", ['@table' => $table, '@field' => $field]));
$this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN `' . $field . '` SET DEFAULT ' . $this->escapeDefaultValue($default));
}
+ /**
+ * {@inheritdoc}
+ */
public function fieldSetNoDefault($table, $field) {
if (!$this->fieldExists($table, $field)) {
throw new SchemaObjectDoesNotExistException(t("Cannot remove default value of field @table.@field: field doesn't exist.", ['@table' => $table, '@field' => $field]));
$this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN `' . $field . '` DROP DEFAULT');
}
+ /**
+ * {@inheritdoc}
+ */
public function indexExists($table, $name) {
// Returns one row for each column in the index. Result is string or FALSE.
// Details at http://dev.mysql.com/doc/refman/5.0/en/show-index.html
return isset($row['Key_name']);
}
+ /**
+ * {@inheritdoc}
+ */
public function addPrimaryKey($table, $fields) {
if (!$this->tableExists($table)) {
throw new SchemaObjectDoesNotExistException(t("Cannot add primary key to table @table: table doesn't exist.", ['@table' => $table]));
$this->connection->query('ALTER TABLE {' . $table . '} ADD PRIMARY KEY (' . $this->createKeySql($fields) . ')');
}
+ /**
+ * {@inheritdoc}
+ */
public function dropPrimaryKey($table) {
if (!$this->indexExists($table, 'PRIMARY')) {
return FALSE;
return TRUE;
}
+ /**
+ * {@inheritdoc}
+ */
public function addUniqueKey($table, $name, $fields) {
if (!$this->tableExists($table)) {
throw new SchemaObjectDoesNotExistException(t("Cannot add unique key @name to table @table: table doesn't exist.", ['@table' => $table, '@name' => $name]));
$this->connection->query('ALTER TABLE {' . $table . '} ADD UNIQUE KEY `' . $name . '` (' . $this->createKeySql($fields) . ')');
}
+ /**
+ * {@inheritdoc}
+ */
public function dropUniqueKey($table, $name) {
if (!$this->indexExists($table, $name)) {
return FALSE;
$this->connection->query('ALTER TABLE {' . $table . '} ADD INDEX `' . $name . '` (' . $this->createKeySql($indexes[$name]) . ')');
}
+ /**
+ * {@inheritdoc}
+ */
public function dropIndex($table, $name) {
if (!$this->indexExists($table, $name)) {
return FALSE;
return TRUE;
}
+ /**
+ * {@inheritdoc}
+ */
public function changeField($table, $field, $field_new, $spec, $keys_new = []) {
if (!$this->fieldExists($table, $field)) {
throw new SchemaObjectDoesNotExistException(t("Cannot change the definition of field @table.@name: field doesn't exist.", ['@table' => $table, '@name' => $field]));
$this->connection->query($sql);
}
+ /**
+ * {@inheritdoc}
+ */
public function prepareComment($comment, $length = NULL) {
// Truncate comment to maximum comment length.
if (isset($length)) {
return preg_replace('/; InnoDB free:.*$/', '', $comment);
}
+ /**
+ * {@inheritdoc}
+ */
public function tableExists($table) {
// The information_schema table is very slow to query under MySQL 5.0.
// Instead, we try to select from the table in question. If it fails,
}
}
+ /**
+ * {@inheritdoc}
+ */
public function fieldExists($table, $column) {
// The information_schema table is very slow to query under MySQL 5.0.
// Instead, we try to select from the table and field in question. If it