mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
NEW Allow querying if a field exists on a table
This commit is contained in:
parent
abbce151d9
commit
cc2e250719
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user