From d2d22aa2d72e9b7b6e11c35071a248296f2f3f66 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Sun, 23 Nov 2008 23:20:43 +0000 Subject: [PATCH] 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 --- core/model/fieldtypes/Boolean.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core/model/fieldtypes/Boolean.php b/core/model/fieldtypes/Boolean.php index d5fc5d0b7..4213f4b76 100644 --- a/core/model/fieldtypes/Boolean.php +++ b/core/model/fieldtypes/Boolean.php @@ -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"; } @@ -41,7 +37,7 @@ class Boolean extends DBField { user_error("DBField::saveInto() Called on a nameless '$this->class' object", E_USER_ERROR); } } - + public function scaffoldFormField($title = null, $params = null) { return new CheckboxField($this->name, $title); } @@ -51,14 +47,18 @@ 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'"; + } }