Created
October 26, 2012 09:11
-
-
Save yuka2py/3957781 to your computer and use it in GitHub Desktop.
appfogでDBへの接続情報を取得する
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 | |
$services_json = getenv('VCAP_SERVICES'); | |
$services = json_decode($services_json, true); | |
$config = null; | |
foreach ($services as $name => $service) { | |
if (0 === stripos($name, 'mysql')) { | |
$config = $service[0]['credentials']; | |
break; | |
} | |
} | |
is_null($config) && die('MySQL service information not found.'); | |
$db_hostname = $config["hostname"]; | |
$db_hostport = $config["port"]; | |
$db_username = $config["user"]; | |
$db_password = $config["password"]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment