[*] 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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user