[*] Installer : added timout to sql connection

This commit is contained in:
dMetzger
2012-08-07 12:32:40 +00:00
parent e39ce99efe
commit dcbb07649b
4 changed files with 14 additions and 7 deletions
+9 -3
View File
@@ -161,10 +161,16 @@ class DbMySQLiCore extends Db
/**
* @see Db::checkConnection()
*/
static public function tryToConnect($server, $user, $pwd, $db, $newDbLink = true, $engine = null)
public static function tryToConnect($server, $user, $pwd, $db, $newDbLink = true, $engine = null, $timeout = 5)
{
$link = @new mysqli($server, $user, $pwd, $db);
if (mysqli_connect_error())
$link = mysqli_init();
if (!$link)
return -1;
if (!$link->options(MYSQLI_OPT_CONNECT_TIMEOUT, $timeout))
return 1;
if (!$link->real_connect($server, $user, $pwd, $db);
return (mysqli_connect_errno() == 1049) ? 2 : 1;
if (strtolower($engine) == 'innodb')