From 3878730edfa4bf2b2cac211a51fecd0863f1a951 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Sat, 21 Nov 2009 01:41:24 +0000 Subject: [PATCH] API CHANGE: Added Lower and Upper methods to Varchar, Text, and Enum (from r91048) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@92452 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/fieldtypes/Enum.php | 7 +++++++ core/model/fieldtypes/StringField.php | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/core/model/fieldtypes/Enum.php b/core/model/fieldtypes/Enum.php index ecdf026ac..eed5b4017 100755 --- a/core/model/fieldtypes/Enum.php +++ b/core/model/fieldtypes/Enum.php @@ -74,6 +74,13 @@ class Enum extends DBField { function enumValues($hasEmpty = false) { return ($hasEmpty) ? array_merge(array('' => ''), ArrayLib::valuekey($this->enum)) : ArrayLib::valuekey($this->enum); } + + function Lower() { + return StringField::Lower(); + } + function Upper() { + return StringField::Upper(); + } } ?> diff --git a/core/model/fieldtypes/StringField.php b/core/model/fieldtypes/StringField.php index c59dee366..690bfcdaf 100644 --- a/core/model/fieldtypes/StringField.php +++ b/core/model/fieldtypes/StringField.php @@ -76,4 +76,19 @@ abstract class StringField extends DBField { } } + + /** + * Return another DBField object with this value in lowercase. + */ + function Lower() { + return DBField::create(get_class($this), strtolower($this->value), $this->name); + } + + /** + * Return another DBField object with this value in uppercase. + */ + function Upper() { + return DBField::create(get_class($this), strtoupper($this->value), $this->name); + } + }