मैंने ऐसा करके काम किया है।
वैश्विक उपयोग
define('DB_HOST', getenv('OPENSHIFT_MYSQL_DB_HOST'));
define('DB_PORT', getenv('OPENSHIFT_MYSQL_DB_PORT'));
define('DB_USER', getenv('OPENSHIFT_MYSQL_DB_USERNAME'));
define('DB_PASS', getenv('OPENSHIFT_MYSQL_DB_PASSWORD'));
define('DB_NAME', getenv('OPENSHIFT_GEAR_NAME'));
$dbhost = constant("DB_HOST"); // Host name
$dbport = constant("DB_PORT"); // Host port
$dbusername = constant("DB_USER"); // MySQL username
$dbpassword = constant("DB_PASS"); // MySQL password
$db_name = constant("DB_NAME"); // Database name
वैकल्पिक रूप से
$dbhost = getenv('OPENSHIFT_MYSQL_DB_HOST'); // Host name
$dbport = getenv('OPENSHIFT_MYSQL_DB_PORT'); // Host port
$dbusername = getenv('OPENSHIFT_MYSQL_DB_USERNAME'); // MySQL username
$dbpassword = getenv('OPENSHIFT_MYSQL_DB_PASSWORD'); // MySQL password
$db_name = getenv('OPENSHIFT_GEAR_NAME'); // Database name