diff --git a/model/Database.php b/model/Database.php index d76f73853..7e32cd114 100644 --- a/model/Database.php +++ b/model/Database.php @@ -143,7 +143,7 @@ abstract class SS_Database { * Returns true if the given table exists in the database */ abstract function hasTable($tableName); - + /** * Returns the enum values available on the given field */ @@ -439,6 +439,18 @@ abstract class SS_Database { } } + /** + * Return true if the table exists and already has a the field specified + * @param string $tableName - The table to check + * @param string $fieldName - The field to check + * @return bool - True if the table exists and the field exists on the table + */ + function hasField($tableName, $fieldName) { + if (!$this->hasTable($tableName)) return false; + $fields = $this->fieldList($tableName); + return array_key_exists($fieldName, $fields); + } + /** * Generate the given field on the table, modifying whatever already exists as necessary. * @param string $table The table name.