Last active
December 10, 2015 09:28
-
-
Save Axiol/4414178 to your computer and use it in GitHub Desktop.
Use multiple database configuration depending of the adress you access the service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public $local = array( | |
'datasource' => 'Database/Mysql', | |
'persistent' => false, | |
'host' => '', | |
'login' => '', | |
'password' => '', | |
'database' => '', | |
'prefix' => '', | |
'encoding' => '', | |
); | |
public $prod = array( | |
'datasource' => 'Database/Mysql', | |
'persistent' => false, | |
'host' => '', | |
'login' => '', | |
'password' => '', | |
'database' => '', | |
'prefix' => '', | |
'encoding' => '', | |
); | |
public function __construct() { | |
if(isset($_SERVER['SERVER_NAME'])){ | |
switch($_SERVER['SERVER_NAME']){ | |
case 'localhost': | |
$this->default = $this->local; | |
break; | |
case 'your.project.com': | |
$this->default = $this->prod; | |
break; | |
default: | |
$this->default = $this->prod; | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment