From 8b73690f23717a9d2c99ab74b16a34a8b91f15ec Mon Sep 17 00:00:00 2001 From: Julian Seidenberg Date: Fri, 4 Sep 2009 01:38:29 +0000 Subject: [PATCH] ENHANCEMENT: Ticket #3910 - MySQL Time Zone support (alternative time zone to that of the website to which the server is set to) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@85716 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/MySQLDatabase.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/model/MySQLDatabase.php b/core/model/MySQLDatabase.php index cf25f3fa5..7f0a2a646 100644 --- a/core/model/MySQLDatabase.php +++ b/core/model/MySQLDatabase.php @@ -49,6 +49,7 @@ class MySQLDatabase extends Database { * - username: The username to log on with * - password: The password to log on with * - database: The database to connect to + * - timezone: (optional) the timezone offset, eg: +12:00 for NZ time */ public function __construct($parameters) { $this->dbConn = mysql_connect($parameters['server'], $parameters['username'], $parameters['password']); @@ -60,6 +61,9 @@ class MySQLDatabase extends Database { $this->active = mysql_select_db($parameters['database'], $this->dbConn); $this->database = $parameters['database']; + if(isset($parameters['timezone'])) { //set timezone to custom parameter + mysql_query("SET SESSION time_zone='" . $parameters['timezone'] . "'"); + } if(!$this->dbConn) { $this->databaseError("Couldn't connect to MySQL database"); }