Skip to content

Instantly share code, notes, and snippets.

@Axiol
Last active December 10, 2015 09:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Axiol/4414178 to your computer and use it in GitHub Desktop.
Save Axiol/4414178 to your computer and use it in GitHub Desktop.
Use multiple database configuration depending of the adress you access the service
<?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