summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-03-28 11:45:11 +0000
committerDries Buytaert <dries@buytaert.net>2010-03-28 11:45:11 +0000
commita08c9696694cee8a41effd7cb6527f9d1e9ca5e0 (patch)
tree890d8ac23afb9c5d25c42c2ac18a1feffad8a388 /includes
parent00ecc0a208cf498c7e5e2e734364f62509f1be6e (diff)
downloadbrdo-a08c9696694cee8a41effd7cb6527f9d1e9ca5e0.tar.gz
brdo-a08c9696694cee8a41effd7cb6527f9d1e9ca5e0.tar.bz2
- Patch #728338 by sun, Crell: standardize on 'field' in function names. 'It has to get worse before it can get better.'
Diffstat (limited to 'includes')
-rw-r--r--includes/database/database.inc8
-rw-r--r--includes/database/mysql/schema.inc12
-rw-r--r--includes/database/pgsql/schema.inc12
-rw-r--r--includes/database/schema.inc2
-rw-r--r--includes/database/sqlite/schema.inc14
5 files changed, 24 insertions, 24 deletions
diff --git a/includes/database/database.inc b/includes/database/database.inc
index 240c3c659..6b0894620 100644
--- a/includes/database/database.inc
+++ b/includes/database/database.inc
@@ -2571,14 +2571,14 @@ function db_table_exists($table) {
*
* @param $table
* The name of the table in drupal (no prefixing).
- * @param $name
- * The name of the column.
+ * @param $field
+ * The name of the field.
*
* @return
* TRUE if the given column exists, otherwise FALSE.
*/
-function db_column_exists($table, $column) {
- return Database::getConnection()->schema()->columnExists($table, $column);
+function db_field_exists($table, $field) {
+ return Database::getConnection()->schema()->fieldExists($table, $field);
}
/**
diff --git a/includes/database/mysql/schema.inc b/includes/database/mysql/schema.inc
index 2b9ca71ca..9af75fd50 100644
--- a/includes/database/mysql/schema.inc
+++ b/includes/database/mysql/schema.inc
@@ -289,7 +289,7 @@ class DatabaseSchema_mysql extends DatabaseSchema {
if (!$this->tableExists($table)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add field %table.%field: table doesn't exist.", array('%field' => $field, '%table' => $table)));
}
- if ($this->columnExists($table, $field)) {
+ if ($this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectExistsException(t("Cannot add field %table.%field: field already exists.", array('%field' => $field, '%table' => $table)));
}
@@ -316,7 +316,7 @@ class DatabaseSchema_mysql extends DatabaseSchema {
}
public function dropField($table, $field) {
- if (!$this->columnExists($table, $field)) {
+ if (!$this->fieldExists($table, $field)) {
return FALSE;
}
@@ -325,7 +325,7 @@ class DatabaseSchema_mysql extends DatabaseSchema {
}
public function fieldSetDefault($table, $field, $default) {
- if (!$this->columnExists($table, $field)) {
+ if (!$this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot set default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
}
@@ -340,7 +340,7 @@ class DatabaseSchema_mysql extends DatabaseSchema {
}
public function fieldSetNoDefault($table, $field) {
- if (!$this->columnExists($table, $field)) {
+ if (!$this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot remove default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
}
@@ -415,10 +415,10 @@ class DatabaseSchema_mysql extends DatabaseSchema {
}
public function changeField($table, $field, $field_new, $spec, $keys_new = array()) {
- if (!$this->columnExists($table, $field)) {
+ if (!$this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot change the definition of field %table.%name: field doesn't exist.", array('%table' => $table, '%name' => $field)));
}
- if (($field != $field_new) && $this->columnExists($table, $field_new)) {
+ if (($field != $field_new) && $this->fieldExists($table, $field_new)) {
throw new DatabaseSchemaObjectExistsException(t("Cannot rename field %table.%name to %name_new: target field already exists.", array('%table' => $table, '%name' => $field, '%name_new' => $field_new)));
}
diff --git a/includes/database/pgsql/schema.inc b/includes/database/pgsql/schema.inc
index 1306bbd3a..fcff331fb 100644
--- a/includes/database/pgsql/schema.inc
+++ b/includes/database/pgsql/schema.inc
@@ -313,7 +313,7 @@ class DatabaseSchema_pgsql extends DatabaseSchema {
if (!$this->tableExists($table)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add field %table.%field: table doesn't exist.", array('%field' => $field, '%table' => $table)));
}
- if ($this->columnExists($table, $field)) {
+ if ($this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectExistsException(t("Cannot add field %table.%field: field already exists.", array('%field' => $field, '%table' => $table)));
}
@@ -343,7 +343,7 @@ class DatabaseSchema_pgsql extends DatabaseSchema {
}
public function dropField($table, $field) {
- if (!$this->columnExists($table, $field)) {
+ if (!$this->fieldExists($table, $field)) {
return FALSE;
}
@@ -352,7 +352,7 @@ class DatabaseSchema_pgsql extends DatabaseSchema {
}
public function fieldSetDefault($table, $field, $default) {
- if (!$this->columnExists($table, $field)) {
+ if (!$this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot set default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
}
@@ -367,7 +367,7 @@ class DatabaseSchema_pgsql extends DatabaseSchema {
}
public function fieldSetNoDefault($table, $field) {
- if (!$this->columnExists($table, $field)) {
+ if (!$this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot remove default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
}
@@ -457,10 +457,10 @@ class DatabaseSchema_pgsql extends DatabaseSchema {
}
public function changeField($table, $field, $field_new, $spec, $new_keys = array()) {
- if (!$this->columnExists($table, $field)) {
+ if (!$this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot change the definition of field %table.%name: field doesn't exist.", array('%table' => $table, '%name' => $field)));
}
- if (($field != $field_new) && $this->columnExists($table, $field_new)) {
+ if (($field != $field_new) && $this->fieldExists($table, $field_new)) {
throw new DatabaseSchemaObjectExistsException(t("Cannot rename field %table.%name to %name_new: target field already exists.", array('%table' => $table, '%name' => $field, '%name_new' => $field_new)));
}
diff --git a/includes/database/schema.inc b/includes/database/schema.inc
index 096124532..ab2a95a03 100644
--- a/includes/database/schema.inc
+++ b/includes/database/schema.inc
@@ -252,7 +252,7 @@ abstract class DatabaseSchema implements QueryPlaceholderInterface {
* @return
* TRUE if the given column exists, otherwise FALSE.
*/
- public function columnExists($table, $column) {
+ public function fieldExists($table, $column) {
$condition = $this->buildTableNameCondition($this->connection->prefixTables('{' . $table . '}'));
$condition->condition('column_name', $column);
$condition->compile($this->connection, $this);
diff --git a/includes/database/sqlite/schema.inc b/includes/database/sqlite/schema.inc
index aa0e203f1..894d51c63 100644
--- a/includes/database/sqlite/schema.inc
+++ b/includes/database/sqlite/schema.inc
@@ -19,7 +19,7 @@ class DatabaseSchema_sqlite extends DatabaseSchema {
return (bool) $this->connection->query("SELECT name FROM sqlite_master WHERE type = 'table' AND name LIKE '{" . $table . "}'", array(), array())->fetchField();
}
- public function columnExists($table, $column) {
+ public function fieldExists($table, $column) {
$schema = $this->introspectSchema($table);
return !empty($schema['fields'][$column]);
}
@@ -262,7 +262,7 @@ class DatabaseSchema_sqlite extends DatabaseSchema {
if (!$this->tableExists($table)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add field %table.%field: table doesn't exist.", array('%field' => $field, '%table' => $table)));
}
- if ($this->columnExists($table, $field)) {
+ if ($this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectExistsException(t("Cannot add field %table.%field: field already exists.", array('%field' => $field, '%table' => $table)));
}
@@ -377,7 +377,7 @@ class DatabaseSchema_sqlite extends DatabaseSchema {
}
public function dropField($table, $field) {
- if ($this->columnExists($table, $field)) {
+ if ($this->fieldExists($table, $field)) {
return FALSE;
}
@@ -399,10 +399,10 @@ class DatabaseSchema_sqlite extends DatabaseSchema {
}
public function changeField($table, $field, $field_new, $spec, $keys_new = array()) {
- if (!$this->columnExists($table, $field)) {
+ if (!$this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot change the definition of field %table.%name: field doesn't exist.", array('%table' => $table, '%name' => $field)));
}
- if (($field != $field_new) && $this->columnExists($table, $field_new)) {
+ if (($field != $field_new) && $this->fieldExists($table, $field_new)) {
throw new DatabaseSchemaObjectExistsException(t("Cannot rename field %table.%name to %name_new: target field already exists.", array('%table' => $table, '%name' => $field, '%name_new' => $field_new)));
}
@@ -499,7 +499,7 @@ class DatabaseSchema_sqlite extends DatabaseSchema {
}
public function fieldSetDefault($table, $field, $default) {
- if (!$this->columnExists($table, $field)) {
+ if (!$this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot set default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
}
@@ -509,7 +509,7 @@ class DatabaseSchema_sqlite extends DatabaseSchema {
}
public function fieldSetNoDefault($table, $field) {
- if (!$this->columnExists($table, $field)) {
+ if (!$this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot remove default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
}