Created
June 16, 2011 13:28
-
-
Save pascaldevink/1029225 to your computer and use it in GitHub Desktop.
Orchestra configuration solution
This file contains hidden or 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
| 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