Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

BUGFIX Updating MySQLDatabaseConfigurationHelper to check for MySQLi

instead of mysql_connect and other old function usage, as we've moved to
MySQLi in MySQLDatabase.php now
  • Loading branch information...
commit b03cf04dbd60219dc4f758030f3492bb0539a70f 1 parent c7ca63e
Sean Harvey halkyon authored
2  _register_database.php
View
@@ -8,7 +8,7 @@
'class' => 'MySQLDatabase',
'title' => 'MySQL 5.0+',
'helperPath' => $frameworkPath . '/dev/install/MySQLDatabaseConfigurationHelper.php',
- 'supported' => function_exists('mysql_connect'),
+ 'supported' => class_exists('MySQLi'),
)
);
28 dev/install/MySQLDatabaseConfigurationHelper.php
View
@@ -18,7 +18,7 @@ class MySQLDatabaseConfigurationHelper implements DatabaseConfigurationHelper {
* @return boolean
*/
public function requireDatabaseFunctions($databaseConfig) {
- return (function_exists('mysql_connect')) ? true : false;
+ return class_exists('MySQLi');
}
/**
@@ -29,12 +29,12 @@ public function requireDatabaseFunctions($databaseConfig) {
public function requireDatabaseServer($databaseConfig) {
$success = false;
$error = '';
- $conn = @mysql_connect($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password']);
- if($conn || mysql_errno() < 2000) {
+ $conn = new MySQLi($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password']);
+ if($conn && $conn->connect_errno < 2000) {
$success = true;
} else {
$success = false;
- $error = mysql_error();
+ $error = ($conn) ? $conn->connect_error : '';
}
return array(
'success' => $success,
@@ -48,13 +48,13 @@ public function requireDatabaseServer($databaseConfig) {
* @return mixed string Version number as string | boolean FALSE on failure
*/
public function getDatabaseVersion($databaseConfig) {
- $conn = @mysql_connect($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password']);
+ $conn = new MySQLi($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password']);
if(!$conn) return false;
- $version = @mysql_get_server_info($conn);
+ $version = $conn->server_info;
if(!$version) {
// fallback to trying a query
- $result = @mysql_query("SELECT VERSION()");
- $row = @mysql_fetch_array($result);
+ $result = $conn->query('SELECT VERSION()');
+ $row = $result->fetch_array();
if($row && isset($row[0])) {
$version = trim($row[0]);
}
@@ -93,12 +93,12 @@ public function requireDatabaseVersion($databaseConfig) {
public function requireDatabaseConnection($databaseConfig) {
$success = false;
$error = '';
- $conn = @mysql_connect($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password']);
+ $conn = new MySQLi($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password']);
if($conn) {
$success = true;
} else {
$success = false;
- $error = mysql_error();
+ $error = ($conn) ? $conn->connect_error : '';
}
return array(
'success' => $success,
@@ -116,13 +116,13 @@ public function requireDatabaseConnection($databaseConfig) {
public function requireDatabaseOrCreatePermissions($databaseConfig) {
$success = false;
$alreadyExists = false;
- $conn = @mysql_connect($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password']);
- if(@mysql_select_db($databaseConfig['database'], $conn)) {
+ $conn = new MySQLi($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password']);
+ if($conn && $conn->select_db($databaseConfig['database'])) {
$success = true;
$alreadyExists = true;
} else {
- if(@mysql_query("CREATE DATABASE testing123", $conn)) {
- mysql_query("DROP DATABASE testing123", $conn);
+ if($conn && $conn->query('CREATE DATABASE testing123')) {
+ mysql_query('DROP DATABASE testing123', $conn);
$success = true;
$alreadyExists = false;
}
Please sign in to comment.
Something went wrong with that request. Please try again.