Skip to content

Instantly share code, notes, and snippets.

@taiko19xx
Created November 12, 2016 03:56
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save taiko19xx/139315231895ab26ae22cf0af46aec85 to your computer and use it in GitHub Desktop.
Save taiko19xx/139315231895ab26ae22cf0af46aec85 to your computer and use it in GitHub Desktop.
Get "MySQL In App(Azure)" connection string.
<?php
define('ENV_STR', 'MYSQLCONNSTR_localdb');
$return = array('result' => false);
if (isset($_SERVER[ENV_STR])) {
$connectStr = $_SERVER[ENV_STR];
$return['connection'] = array(
'host' => preg_replace("/^.*Data Source=(.+?);.*$/", "\\1", $connectStr),
'database' => preg_replace("/^.*Database=(.+?);.*$/", "\\1", $connectStr),
'user' => preg_replace("/^.*User Id=(.+?);.*$/", "\\1", $connectStr),
'password' => preg_replace("/^.*Password=(.+?)$/", "\\1", $connectStr)
);
$return['result'] = true;
}
header('Content-Type: application/json; charset=utf-8');
echo json_encode($return);
@scottaBPC
Copy link

Can I ask which parts of this code would be changed to retreive the local web app details and connect? Are there any specific parts that I would be needing to change? thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment