mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
5a98e83f7a
commit
d2d22aa2d7
@ -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'";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user