summaryrefslogtreecommitdiff
path: root/installer/installer.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-06-13 17:06:34 -0700
committerBharat Mediratta <bharat@menalto.com>2009-06-13 17:06:34 -0700
commit52ac0e71726bae4e0b6c5aed0c92308d49b3f933 (patch)
treee33c961a75efd3bd847fcdd8249660458a73b95b /installer/installer.php
parent5f878e169f7b55c1bd0143305d6ba23f84b3a22e (diff)
Remap mysql_xx() functions to their mysqli counterparts if the mysql
extension is unavailable. Fixes ticket #393.
Diffstat (limited to 'installer/installer.php')
-rw-r--r--installer/installer.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/installer/installer.php b/installer/installer.php
index 1a36ddb5..9ba88bea 100644
--- a/installer/installer.php
+++ b/installer/installer.php
@@ -17,7 +17,35 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
+
+// We know that we have either mysql or mysqli. By default we use mysql functions, so if they're
+// not defined then do the simplest thing which will work: remap them to their mysqli
+// counterparts.
+if (!function_exists("mysql_query")) {
+ function mysql_connect($host, $user, $pass) {
+ installer::$mysqli = new mysqli($host, $user, $pass);
+ // http://php.net/manual/en/mysqli.connect.php says to use mysqli_connect_error() instead of
+ // $mysqli->connect_error because of bugs before PHP 5.2.9
+ $error = mysqli_connect_error();
+ return empty($error);
+ }
+ function mysql_query($query) {
+ return installer::$mysqli->query($query);
+ }
+ function mysql_num_rows($result) {
+ return $result->num_rows;
+ }
+ function mysql_error() {
+ return installer::$mysqli->error;
+ }
+ function mysql_select_db($db) {
+ return installer::$mysqli->select_db($db);
+ }
+}
+
class installer {
+ static $mysqli;
+
static function already_installed() {
return file_exists(VARPATH . "database.php");
}