Skip to content

Instantly share code, notes, and snippets.

@pascaldevink
Created June 16, 2011 13:28
Show Gist options
  • Select an option

  • Save pascaldevink/1029225 to your computer and use it in GitHub Desktop.

Select an option

Save pascaldevink/1029225 to your computer and use it in GitHub Desktop.
Orchestra configuration solution
class Configuration
{
private static $connection;
/**
* @static
* @return array
*/
public static function getConfig()
{
if (strpos($_SERVER['SERVER_NAME'], 'localhost') > 0) {
return array('host'=>'localhost',
'user'=>'root',
'pass'=>'root',
'name'=>'db_name');
}
else {
return array('host'=>'1.1.1.1',
'user'=>'user',
'pass'=>'password',
'name'=>'db_name');
}
}
/**
* @static
* @return PDO
*/
public static function getConnection()
{
if (self::$connection == null) {
$config = self::getConfig();
self::$connection = new PDO('mysql:host=' . $config['host'] . ';dbname=' . $config['name'],
$config['user'],
$config['pass']);
}
return self::$connection;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment