Skip to content

Instantly share code, notes, and snippets.

@Axiol
Last active Dec 10, 2015
Embed
What would you like to do?
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