mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
1063e5048c
commit
8b73690f23
@ -49,6 +49,7 @@ class MySQLDatabase extends Database {
|
|||||||
* - username: The username to log on with
|
* - username: The username to log on with
|
||||||
* - password: The password to log on with
|
* - password: The password to log on with
|
||||||
* - database: The database to connect to
|
* - database: The database to connect to
|
||||||
|
* - timezone: (optional) the timezone offset, eg: +12:00 for NZ time
|
||||||
*/
|
*/
|
||||||
public function __construct($parameters) {
|
public function __construct($parameters) {
|
||||||
$this->dbConn = mysql_connect($parameters['server'], $parameters['username'], $parameters['password']);
|
$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->active = mysql_select_db($parameters['database'], $this->dbConn);
|
||||||
$this->database = $parameters['database'];
|
$this->database = $parameters['database'];
|
||||||
|
if(isset($parameters['timezone'])) { //set timezone to custom parameter
|
||||||
|
mysql_query("SET SESSION time_zone='" . $parameters['timezone'] . "'");
|
||||||
|
}
|
||||||
if(!$this->dbConn) {
|
if(!$this->dbConn) {
|
||||||
$this->databaseError("Couldn't connect to MySQL database");
|
$this->databaseError("Couldn't connect to MySQL database");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user