Changeset:
1633eeb9e580
https://sourceforge.net/p/mrbs/hg-code/ci/1633eeb9e580b4a73900648d9894937146bc1945
Author:
Campbell Morrison <[email protected]>
Date:
Fri Oct 02 10:16:46 2015 +0100
Log message:
Removed 'mysql' $dbsys config option, now that it is being replaced by 'mysqli'
diffstat:
web/internalconfig.inc.php | 8 +
web/mysql.inc | 598 ---------------------------------------------
web/systemdefaults.inc.php | 3 +-
3 files changed, 9 insertions(+), 600 deletions(-)
diffs (truncated from 633 to 300 lines):
diff -r 6a0a2f7ed7d9 -r 1633eeb9e580 web/internalconfig.inc.php
--- a/web/internalconfig.inc.php Fri Oct 02 09:27:20 2015 +0100
+++ b/web/internalconfig.inc.php Fri Oct 02 10:16:46 2015 +0100
@@ -121,6 +121,14 @@
trigger_error($message, E_USER_WARNING);
}
+if ($dbsys == 'mysql')
+{
+ $dbsys = 'mysqli';
+ $message = "Please check your config file. The 'mysql' option for " .
+ '$dbsys has been removed and you should now use ' . "'mysqli'";
+ trigger_error($message, E_USER_WARNING);
+}
+
/********************************************************
* Checking
diff -r 6a0a2f7ed7d9 -r 1633eeb9e580 web/mysql.inc
--- a/web/mysql.inc Fri Oct 02 09:27:20 2015 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,598 +0,0 @@
-<?php
-// $Id$
-
-// mysql.inc - Simple PHP database support for MySQL.
-// The standard MRBS database connection utilises the following configuration
-// variables:
-// $db_host = The hostname of the database server
-// $db_login = The username to use when connecting to the database
-// $db_password = The database account password
-// $db_database = The database name.
-
-
-// A small utility function (not part of the DB abstraction API) to
-// update a connection handle to the global MRBS connection handle
-// if said handle is null/empty
-function sql_mysql_ensure_handle(&$db_conn)
-{
- if (empty($db_conn))
- {
- global $sql_mysql_conn;
- $db_conn = $sql_mysql_conn;
- }
-}
-
-
-// Free a results handle. You need not call this if you call sql_row or
-// sql_row_keyed until the row returns 0, since sql_row frees the results
-// handle when you finish reading the rows.
-function sql_mysql_free ($r, $db_conn = null)
-{
- sql_mysql_ensure_handle($db_conn);
-
- mysql_free_result($r);
-}
-
-
-// Escapes special characters in a string for use in an SQL statement
-function sql_mysql_escape($str, $db_conn = null)
-{
- sql_mysql_ensure_handle($db_conn);
-
- if (function_exists('mysql_real_escape_string'))
- {
- return mysql_real_escape_string($str, $db_conn);
- }
- else
- {
- return addslashes($str);
- }
-}
-
-
-// Quote a table or column name
-function sql_mysql_quote($identifier)
-{
- return '`' . $identifier . '`';
-}
-
-
-// Execute a non-SELECT SQL command (insert/update/delete).
-// Returns the number of tuples affected if OK (a number >= 0).
-// Returns -1 on error; use sql_error to get the error message.
-function sql_mysql_command ($sql, $db_conn = null)
-{
- sql_mysql_ensure_handle($db_conn);
-
- if (mysql_query($sql, $db_conn))
- {
- return mysql_affected_rows($db_conn);
- }
- return -1;
-}
-
-
-// Execute an SQL query which should return a single non-negative number value.
-// This is a lightweight alternative to sql_query, good for use with count(*)
-// and similar queries. It returns -1 on error or if the query did not return
-// exactly one value, so error checking is somewhat limited.
-// It also returns -1 if the query returns a single NULL value, such as from
-// a MIN or MAX aggregate function applied over no rows.
-function sql_mysql_query1 ($sql, $db_conn = null)
-{
- sql_mysql_ensure_handle($db_conn);
-
- $r = mysql_query($sql, $db_conn);
- if (! $r)
- {
- return -1;
- }
- if (mysql_num_rows($r) != 1 || mysql_num_fields($r) != 1
- || ($result = mysql_result($r, 0, 0)) == "")
- {
- $result = -1;
- }
- mysql_free_result($r);
- return $result;
-}
-
-
-// Execute an SQL query. Returns a database-dependent result handle,
-// which should be passed back to sql_row or sql_row_keyed to get the results.
-// Returns FALSE on error; use sql_error to get the error message.
-function sql_mysql_query ($sql, $db_conn = null)
-{
- sql_mysql_ensure_handle($db_conn);
-
- $r = mysql_query($sql, $db_conn);
- return $r;
-}
-
-
-// Return a row from a result. The first row is 0.
-// The row is returned as an array with index 0=first column, etc.
-// When called with i >= number of rows in the result, cleans up from
-// the query and returns 0.
-// Typical usage: $i = 0; while ((a = sql_row($r, $i++))) { ... }
-function sql_mysql_row ($r, $i, $db_conn = null)
-{
- sql_mysql_ensure_handle($db_conn);
-
- if ($i >= mysql_num_rows($r))
- {
- mysql_free_result($r);
- return 0;
- }
- mysql_data_seek($r, $i);
- return mysql_fetch_row($r);
-}
-
-
-// Return a row from a result as an associative array keyed by field name.
-// The first row is 0.
-// This is actually upward compatible with sql_row since the underlying
-// routing also stores the data under number indexes.
-// When called with i >= number of rows in the result, cleans up from
-// the query and returns 0.
-function sql_mysql_row_keyed ($r, $i, $db_conn = null)
-{
- sql_mysql_ensure_handle($db_conn);
-
- if ($i >= mysql_num_rows($r))
- {
- mysql_free_result($r);
- return 0;
- }
- mysql_data_seek($r, $i);
- // Use _array() rather _assoc() to ensure support
- // for as many PHP versions as possible
- return mysql_fetch_array($r, MYSQL_ASSOC);
-}
-
-
-// Return the number of rows returned by a result handle from sql_query.
-function sql_mysql_count ($r, $db_conn = null)
-{
- sql_mysql_ensure_handle($db_conn);
-
- return mysql_num_rows($r);
-}
-
-
-// Return the value of an autoincrement field from the last insert.
-// Must be called right after an insert on that table!
-function sql_mysql_insert_id($table, $field, $db_conn = null)
-{
- sql_mysql_ensure_handle($db_conn);
-
- return mysql_insert_id($db_conn);
-}
-
-
-// Return the text of the last error message.
-function sql_mysql_error($db_conn = null)
-{
- sql_mysql_ensure_handle($db_conn);
-
- return mysql_error($db_conn);
-}
-
-
-// Begin a transaction, if the database supports it. This is used to
-// improve performance for multiple insert/delete/updates.
-function sql_mysql_begin($db_conn = null)
-{
- $result = sql_mysql_command("START TRANSACTION", $db_conn);
-
- if ($result < 0)
- {
- trigger_error (sql_mysql_error($db_conn), E_USER_WARNING);
- }
-}
-
-
-// Commit (end) a transaction. See sql_begin().
-function sql_mysql_commit($db_conn = null)
-{
- $result = sql_mysql_command("COMMIT", $db_conn);
-
- if ($result < 0)
- {
- trigger_error (sql_mysql_error($db_conn), E_USER_WARNING);
- }
-}
-
-
-// Rollback a transaction. See sql_begin().
-function sql_mysql_rollback($db_conn = null)
-{
- $result = sql_mysql_command("ROLLBACK", $db_conn);
-
- if ($result < 0)
- {
- trigger_error (sql_mysql_error($db_conn), E_USER_WARNING);
- }
-}
-
-
-// Acquire a mutual-exclusion lock on the named table. For portability:
-// This will not lock out SELECTs.
-// It may lock out DELETE/UPDATE/INSERT or not, depending on the
implementation.
-// It will lock out other callers of this routine with the same name argument.
-// It may timeout in 20 seconds and return 0, or may wait forever.
-// It returns 1 when the lock has been acquired.
-// Caller must release the lock with sql_mutex_unlock().
-// Caller must not have more than one mutex at any time.
-// Do not mix this with sql_begin()/sql_end() calls.
-//
-// In MySQL, we avoid table locks, and use low-level locks instead.
-function sql_mysql_mutex_lock($name, $db_conn = null)
-{
- global $sql_mysql_mutex_unlock_name;
-
- sql_mysql_ensure_handle($db_conn);
-
- // GET_LOCK returns 1 if the lock was obtained successfully, 0 if the attempt
- // timed out (for example, because another client has previously locked the
name),
- // or NULL if an error occurred (such as running out of memory or the thread
was
- // killed with mysqladmin kill)
- $r = sql_mysql_query("SELECT GET_LOCK('$name', 20)", $db_conn);
- if ($r === FALSE)
- {
- trigger_error(sql_mysql_error($db_conn), E_USER_WARNING);
- return FALSE;
- }
-
- if ((mysql_num_rows($r) != 1) ||
- (mysql_num_fields($r) != 1) ||
- ($result = mysql_result($r, 0, 0)) === NULL)
- {
- return FALSE;
- }
-
- if ($result == 1)
- {
- $sql_mysql_mutex_unlock_name = $name;
- }
- mysql_free_result($r);
- return $result;
-}
-
-
-// Release a mutual-exclusion lock on the named table. See sql_mutex_unlock.
-function sql_mysql_mutex_unlock($name, $db_conn = null)
-{
- sql_mysql_ensure_handle($db_conn);
-
- global $sql_mysql_mutex_unlock_name;
- sql_mysql_query1("SELECT RELEASE_LOCK('$name')", $db_conn);
- $sql_mysql_mutex_unlock_name = NULL;
-}
-
-
-// Shutdown function to clean up the connection. For internal use only.
-function sql_mysql_cleanup($db_conn = null)
-{
- global $sql_mysql_mutex_unlock_name;
-
- // Release any forgotten locks
------------------------------------------------------------------------------
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits