Beispiel #1
0
$app->configureMode('development', function () use($config) {
    $config->setEnvironment('development');
});
$config->load(array('opentok', 'mysql'), true);
/* ------------------------------------------------------------------------------------------------
 * OpenTok Initialization
 * -----------------------------------------------------------------------------------------------*/
$opentok = new OpenTok($config->opentok('key'), $config->opentok('secret'));
/* ------------------------------------------------------------------------------------------------
 * Setup MySQL
 * -----------------------------------------------------------------------------------------------*/
// mysql - replace user/pw and database name
// Set env vars in /Applications/MAMP/Library/bin/envvars if you are using MAMP
// MYSQL env: export CLEARDB_DATABASE_URL="mysql://root:root@localhost/adserverkit
// MYSQL formate: username:pw@url/database
$mysql_url = parse_url(getenv("CLEARDB_DATABASE_URL") ?: $config->mysql('mysql_url'));
$dbname = substr($mysql_url['path'], 1);
$host = $mysql_url['host'];
if ($mysql_url['port']) {
    $host = $host . ':' . $mysql_url['port'];
}
$con = mysqli_connect($host, $mysql_url['user'], $mysql_url['pass']);
// Check connection
if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// Create database - only do once if db does not exist
// Use our database and create table
$sql = "CREATE DATABASE IF NOT EXISTS {$dbname}";
if (!mysqli_query($con, $sql)) {
    echo "Error creating database: " . mysqli_error($con);