<?php
$host   = getenv("MYSQL_TEST_HOST")   ? getenv("MYSQL_TEST_HOST") : "localhost";
$port   = getenv("MYSQL_TEST_PORT")   ? getenv("MYSQL_TEST_PORT") : 3306;
$user   = getenv("MYSQL_TEST_USER")   ? getenv("MYSQL_TEST_USER") : "root";
$passwd = getenv("MYSQL_TEST_PASSWD") ? getenv("MYSQL_TEST_PASSWD") : "";
$db     = getenv("MYSQL_TEST_DB")     ? getenv("MYSQL_TEST_DB") : "test";

$mysqli = new mysqli($host, $user, $passwd, $db, $port);
if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " .
         $mysqli->connect_error;
}
$r = $mysqli->query("DROP TABLE IF EXISTS test");
var_dump($r);

//test null for host, passwd, & db
$mysqlinull = new mysqli(null, $user, null, null, $port);
if ($mysqlinull->connect_errno) {
    echo "Failed to connect to MySQL: (" . $mysqlinull->connect_errno . ") " .
         $mysqlinull->connect_error;
}
