Updated boolean SQL value generation to be more db-agnostic

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@66423 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2008-11-23 23:20:43 +00:00
parent 5a98e83f7a
commit d2d22aa2d7

View File

@ -18,10 +18,6 @@ class Boolean extends DBField {
DB::requireField($this->tableName, $this->name, $values);
}
function nullValue() {
return 0;
}
function Nice() {
return ($this->value) ? "yes" : "no";
}
@ -51,15 +47,19 @@ class Boolean extends DBField {
* If necessary, this should include quotes.
*/
function prepValueForDB($value) {
if($value === true) {
return 1;
if($value === true || $value === 1) {
return "'1'";
} if(!$value || !is_numeric($value)) {
return "0";
return "'0'";
} else {
return addslashes($value);
}
}
function nullValue() {
return "'0'";
}
}
?>