[*] Project: MySQL::trytoconnect() and MySQL::tryUTF8() methods replaced with Db::checkConnection() and Db::checkEncoding()

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8380 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rMalie
2011-09-07 08:16:43 +00:00
parent 0c7d567451
commit 174947be5b
5 changed files with 151 additions and 41 deletions
+27
View File
@@ -136,6 +136,33 @@ class MySQLCore extends Db
return mysql_select_db($db_name, $this->_link);
}
/**
* @see DbCore::tryConnection()
*/
public function tryConnection($server, $user, $pwd, $db, $newDbLink = true)
{
if (!$link = @mysql_connect($server, $user, $pwd, $newDbLink))
return 1;
if (!@mysql_select_db($db, $link))
return 2;
@mysql_close($link);
return 0;
}
/**
* @see DbCore::tryEncoding()
*/
public function tryEncoding($server, $user, $pwd, $encoding = 'UTF8')
{
$link = @mysql_connect($server, $user, $pwd);
if (!mysql_query('SET NAMES \''.pSQL($encoding).'\'', $link))
$ret = false;
else
$ret = true;
@mysql_close($link);
return $ret;
}
/**
* tryToConnect return 0 if the connection succeed and the database can be selected.
* @since 1.4.4.0, the parameter $newDbLink (default true) has been added.