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
This commit is contained in:
Julian Seidenberg 2009-09-04 01:38:29 +00:00
parent 1063e5048c
commit 8b73690f23

View File

@ -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");
}