From 375d440677c1f79e10d3da68657563443e17f2f6 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Wed, 21 Mar 2012 12:03:11 +1300 Subject: [PATCH] BUGFIX Ensure that values with unicode characters like macrons are saved to the database correctly. Overload the prepStringForDB() method and include an "N" prefix. --- code/MSSQLDatabase.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/code/MSSQLDatabase.php b/code/MSSQLDatabase.php index 06ebd0c..7b467fa 100644 --- a/code/MSSQLDatabase.php +++ b/code/MSSQLDatabase.php @@ -1568,6 +1568,17 @@ class MSSQLDatabase extends SS_Database { } } + /** + * Overload the Database::prepStringForDB() method and include "N" prefix so unicode + * strings are saved to the database correctly. + * + * @param string $string String to be encoded + * @return string Processed string ready for DB + */ + public function prepStringForDB($string) { + return "N'" . Convert::raw2sql($string) . "'"; + } + /** * Function to return an SQL datetime expression for MSSQL * used for querying a datetime in a certain format