Forum Moderators: open
$dbh = mysqli_init();
if (!$dbh) { die('mysqli_init failed'); }
// I don't know if I really need these, but it's in the docs so I thought I'd test it
if (!mysqli_options($dbh, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT = 0')) { die('Setting MYSQLI_INIT_COMMAND failed'); }
if (!mysqli_options($dbh, MYSQLI_OPT_CONNECT_TIMEOUT, 5)) { die('Setting MYSQLI_OPT_CONNECT_TIMEOUT failed'); }
// I'm just plugging in a whitespace and a comma until I figure out how to do this properly
if (!mysqli_real_connect($dbh, '123.45.67.89', '[USERNAME]', '[PASSWORD]', '[DATABASE_NAME]', , , MYSQLI_CLIENT_COMPRESS)) {
// do error stuff
}
What's the latency between these servers?
If the database is local, is there any real advantage to using mysqli_real_connect()?