mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #1301 from simonwelsh/mysqli-port
Allow setting the port for mysql and setting it in _ss_environment
This commit is contained in:
commit
62753d8612
@ -13,6 +13,7 @@
|
||||
* - SS_DATABASE_SERVER: The database server to use, defaulting to localhost
|
||||
* - SS_DATABASE_USERNAME: The database username (mandatory)
|
||||
* - SS_DATABASE_PASSWORD: The database password (mandatory)
|
||||
* - SS_DATABASE_PORT: The database port
|
||||
* - SS_DATABASE_SUFFIX: A suffix to add to the database name.
|
||||
* - SS_DATABASE_PREFIX: A prefix to add to the database name.
|
||||
* - SS_DATABASE_TIMEZONE: Set the database timezone to something other than the system timezone.
|
||||
@ -95,6 +96,11 @@ if(defined('SS_DATABASE_USERNAME') && defined('SS_DATABASE_PASSWORD')) {
|
||||
. (defined('SS_DATABASE_SUFFIX') ? SS_DATABASE_SUFFIX : ''),
|
||||
);
|
||||
|
||||
// Set the port if called for
|
||||
if(defined('SS_DATABASE_PORT')) {
|
||||
$databaseConfig['port'] = SS_DATABASE_PORT;
|
||||
}
|
||||
|
||||
// Set the timezone if called for
|
||||
if (defined('SS_DATABASE_TIMEZONE')) {
|
||||
$databaseConfig['timezone'] = SS_DATABASE_TIMEZONE;
|
||||
|
@ -54,7 +54,12 @@ class MySQLDatabase extends SS_Database {
|
||||
* - timezone: (optional) The timezone offset. For example: +12:00, "Pacific/Auckland", or "SYSTEM"
|
||||
*/
|
||||
public function __construct($parameters) {
|
||||
$this->dbConn = new MySQLi($parameters['server'], $parameters['username'], $parameters['password']);
|
||||
if(!empty($parameters['port'])) {
|
||||
$this->dbConn = new MySQLi($parameters['server'], $parameters['username'], $parameters['password'],
|
||||
'', $parameters['port']);
|
||||
} else {
|
||||
$this->dbConn = new MySQLi($parameters['server'], $parameters['username'], $parameters['password']);
|
||||
}
|
||||
|
||||
if($this->dbConn->connect_error) {
|
||||
$this->databaseError("Couldn't connect to MySQL database | " . $this->dbConn->connect_error);
|
||||
|
Loading…
Reference in New Issue
Block a user