<?php

try {
  $curr_dir = getcwd(); # copy app root dir to var
  chdir(getcwd() . "/../../");
  # NOTE: from global definitions: databaseName = serviceName + "_" + stage;
  $serviceName = basename(getcwd()); # gather name of directory which is also service name
  chdir($curr_dir); # go back to app root dir
  $stage = "staging";

  echo "Connecting to: mysql:socket=localhost:~/SoftwareData/Mysql/service.sock;dbname=".$serviceName."_".$stage."<br/>";
  $dbh = new PDO('mysql:socket=localhost:~/SoftwareData/Mysql/service.sock;dbname='.$serviceName."_".$stage,
    '', ''
  );

  $stmt = $dbh->prepare('select * from test1'); # test1 is a testing database created by init.sql file
  $stmt->execute();
  $results = $stmt->fetchAll();
  var_dump($results);

} catch (PDOException $e) {
  print "Error!: " . $e->getMessage() . "<br/>";
  die();
}

?>

<?php

try {
  $curr_dir = getcwd(); # copy app root dir to var
  chdir(getcwd() . "/../../");
  # NOTE: from global definitions: databaseName = serviceName + "_" + stage;
  $serviceName = basename(getcwd()); # gather name of directory which is also service name
  chdir($curr_dir); # go back to app root dir
  $stage = getenv("PHP_ENV");

  echo "Connecting to: mysql:socket=localhost:~/SoftwareData/Mysql/service.sock;dbname=".$serviceName."_".$stage."<br/>";
  $dbh = new PDO('mysql:socket=localhost:~/SoftwareData/Mysql/service.sock;dbname='.$serviceName."_".$stage,
    '', ''
  );

  $stmt = $dbh->prepare('select * from test1'); # test1 is a testing database created by init.sql file
  $stmt->execute();
  $results = $stmt->fetchAll();
  var_dump($results);

} catch (PDOException $e) {
  print "Error!: " . $e->getMessage() . "<br/>";
  die();
}

?>

Use PHP_ENV for stage on app side.
Use PHP_ENV for stage on app side.

Signed-off-by: Daniel (dmilith) Dettlaff <0df25c85cef740557ee7be110d93fbdb7c899ad6@verknowsys.com>
