Skip to content

Instantly share code, notes, and snippets.

@jz5
Last active May 18, 2017 12:52
Show Gist options
  • Save jz5/3e821729ce8d57e44dec7b3cbc032989 to your computer and use it in GitHub Desktop.
Save jz5/3e821729ce8d57e44dec7b3cbc032989 to your computer and use it in GitHub Desktop.
<?php
$connectstr_dbhost = '';
$connectstr_dbname = '';
$connectstr_dbusername = '';
$connectstr_dbpassword = '';
foreach ($_SERVER as $key => $value) {
if (strpos($key, "MYSQLCONNSTR_") !== 0) {
continue;
}
$connectstr_dbhost = preg_replace("/^.*Data Source=(.+?);.*$/", "\\1", $value);
$connectstr_dbname = preg_replace("/^.*Database=(.+?);.*$/", "\\1", $value);
$connectstr_dbusername = preg_replace("/^.*User Id=(.+?);.*$/", "\\1", $value);
$connectstr_dbpassword = preg_replace("/^.*Password=(.+?)$/", "\\1", $value);
}
/** MySQL hostname */
define('DB_HOST', $connectstr_dbhost);
/** The name of the database for WordPress */
define('DB_NAME', $connectstr_dbname);
/** MySQL database username */
define('DB_USER', $connectstr_dbusername);
/** MySQL database password */
define('DB_PASSWORD', $connectstr_dbpassword);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment