diff --git a/classes/Db.php b/classes/Db.php index d8749b6eb..580c6d781 100644 --- a/classes/Db.php +++ b/classes/Db.php @@ -175,7 +175,7 @@ abstract class DbCore } if (!isset(self::$_instance[$idServer])) - self::$_instance[$idServer] = Db::newInstance(self::$_servers[$idServer]['server'], self::$_servers[$idServer]['user'], self::$_servers[$idServer]['password'], self::$_servers[$idServer]['database']); + self::$_instance[$idServer] = Db::factory(self::$_servers[$idServer]['server'], self::$_servers[$idServer]['user'], self::$_servers[$idServer]['password'], self::$_servers[$idServer]['database']); return self::$_instance[$idServer]; } @@ -190,7 +190,7 @@ abstract class DbCore * @param bool $connect If false, don't connect in constructor * @return Db */ - public static function newInstance($server, $user, $password, $database, $connect = true) + public static function factory($server, $user, $password, $database, $connect = true) { $class = 'MySQL'; if (class_exists('mysqli', false)) @@ -509,8 +509,7 @@ abstract class DbCore */ static public function checkConnection($server, $user, $pwd, $db) { - $instance = Db::newInstance($server, $user, $pwd, $db, false); - return $instance->tryConnection(); + return Db::factory($server, $user, $pwd, $db, false)->tryConnection(); } /** @@ -526,8 +525,7 @@ abstract class DbCore */ static public function checkEncoding($server, $user, $pwd, $encoding = 'UTF8') { - $instance = Db::newInstance($server, $user, $pwd, '', false); - return $instance->tryEncoding($encoding); + return Db::factory($server, $user, $pwd, '', false)->tryEncoding($encoding); } /** diff --git a/classes/MySQL.php b/classes/MySQL.php index ef52da264..5f526943f 100644 --- a/classes/MySQL.php +++ b/classes/MySQL.php @@ -139,7 +139,7 @@ class MySQLCore extends Db /** * @see DbCore::tryConnection() */ - public function tryConnection($server, $user, $pwd, $db, $newDbLink = true) + public function tryConnection($newDbLink = true) { if (!$link = @mysql_connect($server, $user, $pwd, $newDbLink)) return 1; @@ -152,7 +152,7 @@ class MySQLCore extends Db /** * @see DbCore::tryEncoding() */ - public function tryEncoding($server, $user, $pwd, $encoding = 'UTF8') + public function tryEncoding($encoding = 'UTF8') { $link = @mysql_connect($server, $user, $pwd); if (!mysql_query('SET NAMES \''.pSQL($encoding).'\'', $link)) @@ -164,15 +164,7 @@ class MySQLCore extends Db } /** - * 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. - * - * @param string $server mysql server name - * @param string $user mysql user - * @param string $pwd mysql user password - * @param string $db mysql database name - * @param boolean $newDbLink if set to true, the function will not create a new link if one already exists. - * @return integer + * @deprecated since 1.5.0 */ public static function tryToConnect($server, $user, $pwd, $db, $newDbLink = true) { @@ -184,6 +176,9 @@ class MySQLCore extends Db return 0; } + /** + * @deprecated since 1.5.0 + */ static public function tryUTF8($server, $user, $pwd) { $link = @mysql_connect($server, $user, $pwd);