API CHANGE: function RequireField now explained a bit more clearly

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@72427 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Geoff Munn 2009-03-03 21:45:54 +00:00
parent 6a21071e4c
commit 334cfc8f3e

View File

@ -345,19 +345,23 @@ abstract class Database extends Object {
$this->fieldList[$table] = $this->fieldList($table); $this->fieldList[$table] = $this->fieldList($table);
} }
// Get the value of this field.
if(is_array($spec)) if(is_array($spec))
$specValue=$spec['data_type']; $specValue=$spec['data_type'];
else $specValue=$spec; else $specValue=$spec;
// We need to get db-specific versions of the ID column:
if($spec_orig==DB::getConn()->IdColumn())
$specValue=DB::getConn()->IdColumn(true);
if(is_array($this->fieldList[$table][$field])) if(is_array($this->fieldList[$table][$field]))
$fieldValue=$this->fieldList[$table][$field]['data_type']; $fieldValue=$this->fieldList[$table][$field]['data_type'];
else $fieldValue=$this->fieldList[$table][$field]; else $fieldValue=$this->fieldList[$table][$field];
if(is_array($spec_orig)) // Get the version of the field as we would create it. This is used for comparison purposes to see if the
// existing field is different to what we now want
if(is_array($spec_orig)) {
$spec_orig=DB::getConn()->$spec_orig['type']($spec_orig['parts']); $spec_orig=DB::getConn()->$spec_orig['type']($spec_orig['parts']);
if($spec_orig==DB::getConn()->IdColumn()){
$specValue=DB::getConn()->IdColumn(true);
} }
if($newTable || $fieldValue=='') { if($newTable || $fieldValue=='') {