Changeset:
884cad2d2a9f
https://sourceforge.net/p/mrbs/hg-code/ci/884cad2d2a9f01af87bc3182520d55e61860dd6b
Author:
John Beranek <[email protected]>
Date:
Fri Sep 30 22:39:29 2016 +0100
Log message:
Removed the remainder of the sql_*() calls, and the wrapper functions
diffstat:
web/Themes/default/header.inc | 2 +-
web/dbsys.inc | 122 +---------------------------
web/import.php | 8 +-
web/internalconfig.inc.php | 3 +
web/mrbs_sql.inc | 185 ++++++++++++++++++++---------------------
web/upgrade/13/post.inc | 3 +-
web/upgrade/15/post.inc | 6 +-
web/upgrade/16/post.inc | 3 +-
web/upgrade/17/post.inc | 20 ++--
web/upgrade/2/post.inc | 3 +-
web/upgrade/21/post.inc | 6 +-
web/upgrade/24/post.inc | 9 +-
web/upgrade/32/post.inc | 8 +-
web/upgrade/34/post.inc | 8 +-
web/upgrade/4/post.inc | 3 +-
web/upgrade/43/post.inc | 3 +-
web/upgrade/47/post.inc | 10 +-
web/upgrade/5/post.inc | 2 +-
web/upgrade/6/post.inc | 9 +-
web/upgrade/7/post.inc | 9 +-
web/upgrade/8/post.inc | 4 +-
21 files changed, 159 insertions(+), 267 deletions(-)
diffs (truncated from 1233 to 300 lines):
diff -r 8452098c0f9d -r 884cad2d2a9f web/Themes/default/header.inc
--- a/web/Themes/default/header.inc Fri Sep 30 22:08:01 2016 +0100
+++ b/web/Themes/default/header.inc Fri Sep 30 22:39:29 2016 +0100
@@ -170,7 +170,7 @@
$sql .= " AND create_by=?";
$sql_params[] = $user;
}
- $n_outstanding = sql_query1($sql, $sql_params);
+ $n_outstanding = db()->query1($sql, $sql_params);
echo "<div id=\"n_outstanding\"" .
(($n_outstanding > 0) ? " class=\"outstanding\"" : '') .
">\n";
diff -r 8452098c0f9d -r 884cad2d2a9f web/dbsys.inc
--- a/web/dbsys.inc Fri Sep 30 22:08:01 2016 +0100
+++ b/web/dbsys.inc Fri Sep 30 22:39:29 2016 +0100
@@ -27,8 +27,8 @@
$db_schema_version = 49;
$local_db_schema_version = 1;
-// Convenience wrapper functions
-
+// Convenience wrapper function to provide access to a DB object for
+// default MRBS database
function db()
{
static $db_obj = null;
@@ -45,124 +45,6 @@
}
-function sql_free($stmt)
-{
- return $stmt->free();
-}
-function sql_quote($identifier)
-{
- return DB::default_db()->quote($identifier);
-}
-function sql_command($sql, $params = null)
-{
- return DB::default_db()->command($sql, $params);
-}
-function sql_query1($sql, $params = null)
-{
- return DB::default_db()->query1($sql, $params);
-}
-function sql_query_array($sql, $params = null)
-{
- return DB::default_db()->query_array($sql, $params);
-}
-function sql_query($sql, $params = null)
-{
- return DB::default_db()->query($sql, $params);
-}
-function sql_row($stmt, $i)
-{
- return $stmt->row($i);
-}
-function sql_row_keyed($stmt, $i)
-{
- return $stmt->row_keyed($i);
-}
-function sql_all_rows_keyed($stmt)
-{
- return $stmt->all_rows_keyed();
-}
-function sql_count($stmt)
-{
- return $stmt->count();
-}
-function sql_insert_id($table, $field)
-{
- return DB::default_db()->insert_id($table, $field);
-}
-function sql_error()
-{
- return DB::default_db()->error();
-}
-function sql_begin()
-{
- return DB::default_db()->begin();
-}
-function sql_commit()
-{
- return DB::default_db()->commit();
-}
-function sql_rollback()
-{
- return DB::default_db()->rollback();
-}
-function sql_mutex_lock($name)
-{
- return DB::default_db()->mutex_lock($name);
-}
-function sql_mutex_unlock($name)
-{
- return DB::default_db()->mutex_unlock($name);
-}
-function sql_version()
-{
- return DB::default_db()->version();
-}
-function sql_syntax_limit($count, $offset)
-{
- return DB::default_db()->syntax_limit($count, $offset);
-}
-function sql_syntax_timestamp_to_unix($fieldname)
-{
- return DB::default_db()->syntax_timestamp_to_unix($fieldname);
-}
-function sql_syntax_casesensitive_equals($fieldname, $s, &$params)
-{
- return DB::default_db()->syntax_casesensitive_equals($fieldname, $s,
$params);
-}
-function sql_syntax_caseless_contains($fieldname, $s, &$params)
-{
- return DB::default_db()->syntax_caseless_contains($fieldname, $s, $params);
-}
-function sql_syntax_addcolumn_after($fieldname)
-{
- return DB::default_db()->syntax_addcolumn_after($fieldname);
-}
-function sql_syntax_createtable_autoincrementcolumn()
-{
- return DB::default_db()->syntax_createtable_autoincrementcolumn();
-}
-function sql_syntax_bitwise_xor()
-{
- return DB::default_db()->syntax_bitwise_xor();
-}
-function sql_num_fields($stmt)
-{
- return $stmt->num_fields();
-}
-function sql_table_exists($table)
-{
- return DB::default_db()->table_exists($table);
-}
-function sql_field_exists($table, $field)
-{
- return DB::default_db()->field_exists($table, $field);
-}
-function sql_field_info($table)
-{
- return DB::default_db()->field_info($table);
-}
-
-
// Get a database username and password
function db_get_userpass()
{
diff -r 8452098c0f9d -r 884cad2d2a9f web/import.php
--- a/web/import.php Fri Sep 30 22:08:01 2016 +0100
+++ b/web/import.php Fri Sep 30 22:39:29 2016 +0100
@@ -79,7 +79,7 @@
if ($location_area == '')
{
$sql = "SELECT COUNT(*) FROM $tbl_room WHERE room_name=?";
- $count = sql_query1($sql, array($location_room));
+ $count = db()->query1($sql, array($location_room));
if ($count == 0)
{
@@ -94,7 +94,7 @@
else // we've got a unique room name
{
$sql = "SELECT id FROM $tbl_room WHERE room_name=? LIMIT 1";
- $id = sql_query1($sql, array($location_room));
+ $id = db()->query1($sql, array($location_room));
return $id;
}
}
@@ -107,7 +107,7 @@
FROM $tbl_area
WHERE area_name=?
LIMIT 1";
- $area_id = sql_query1($sql, array($location_area));
+ $area_id = db()->query1($sql, array($location_area));
if ($area_id < 0)
{
// The area does not exist - create it if we are allowed to
@@ -135,7 +135,7 @@
WHERE room_name=?
AND area_id=?
LIMIT 1";
- $room_id = sql_query1($sql, array($location_room, $area_id));
+ $room_id = db()->query1($sql, array($location_room, $area_id));
if ($room_id < 0)
{
// The room does not exist - create it if we are allowed to
diff -r 8452098c0f9d -r 884cad2d2a9f web/internalconfig.inc.php
--- a/web/internalconfig.inc.php Fri Sep 30 22:08:01 2016 +0100
+++ b/web/internalconfig.inc.php Fri Sep 30 22:39:29 2016 +0100
@@ -529,3 +529,6 @@
error_reporting ($error_level);
set_error_handler(__NAMESPACE__ . "\\error_handler");
set_exception_handler(__NAMESPACE__ . "\\exception_handler");
+
+error_reporting(-1);
+ini_set('display_errors', '1');
diff -r 8452098c0f9d -r 884cad2d2a9f web/mrbs_sql.inc
--- a/web/mrbs_sql.inc Fri Sep 30 22:08:01 2016 +0100
+++ b/web/mrbs_sql.inc Fri Sep 30 22:39:29 2016 +0100
@@ -52,11 +52,10 @@
}
$sql .= " ORDER BY start_time";
- $res = sql_query($sql, $sql_params);
+ $res = db()->query($sql, $sql_params);
- if (sql_count($res) == 0)
+ if ($res->count() == 0)
{
- sql_free($res);
return "";
}
// Get the room's area ID for linking to day, week, and month views:
@@ -64,7 +63,7 @@
// Build an listing all the conflicts:
$err = array();
- for ($i = 0; ($row = sql_row_keyed($res, $i)); $i++)
+ for ($i = 0; ($row = $res->row_keyed($i)); $i++)
{
$starts = getdate($row['start_time']);
$param_ym = "area=$area&year=$starts[year]&month=".$starts['mon'];
@@ -203,7 +202,7 @@
$sql_params[] = $repignore;
}
- $existing[$location][$interval_type][$interval_start] = sql_query1($sql,
$sql_params);
+ $existing[$location][$interval_type][$interval_start] =
db()->query1($sql, $sql_params);
$proposed[$location][$interval_type][$interval_start] = 1;
}
else
@@ -448,10 +447,9 @@
WHERE id=?
LIMIT 1";
- $res = sql_query($sql, array($id));
+ $res = db()->query($sql, array($id));
- $result = (sql_count($res) == 0) ? NULL : sql_row_keyed($res, 0);
- sql_free($res);
+ $result = ($res->count() == 0) ? NULL : $res->row_keyed(0);
return $result;
}
@@ -472,10 +470,9 @@
AND start_time <= ? AND end_time > ?
ORDER BY start_time"; // necessary so that multiple bookings appear
in the right order
- $res = sql_query($sql, array($area_id, $interval_end, $interval_start));
+ $res = db()->query($sql, array($area_id, $interval_end, $interval_start));
- $result = sql_all_rows_keyed($res);
- sql_free($res);
+ $result = $res->all_rows_keyed();
return $result;
}
@@ -494,10 +491,9 @@
AND start_time <= ? AND end_time > ?
ORDER BY start_time"; // necessary so that multiple bookings appear
in the right order
- $res = sql_query($sql, array($room_id, $interval_end, $interval_start));
+ $res = db()->query($sql, array($room_id, $interval_end, $interval_start));
- $result = sql_all_rows_keyed($res);
- sql_free($res);
+ $result = $res->all_rows_keyed();
return $result;
}
@@ -523,12 +519,12 @@
$start_times = array();
// Get the repeat_id and room_id for this entry
- $res = sql_query("SELECT repeat_id, room_id FROM $tbl_entry WHERE id=? LIMIT
1", array($id));
- if (sql_count($res) <= 0)
+ $res = db()->query("SELECT repeat_id, room_id FROM $tbl_entry WHERE id=?
LIMIT 1", array($id));
+ if ($res->count() <= 0)
{
return FALSE;
}
- $row = sql_row_keyed($res, 0);
+ $row = $res->row_keyed(0);
$repeat_id = $row['repeat_id'];
$room_id = $row['room_id'];
@@ -547,9 +543,9 @@
$sql_params[] = $id;
}
- $res = sql_query($sql, $sql_params);
+ $res = db()->query($sql, $sql_params);
- for ($i = 0; ($row = sql_row_keyed($res, $i)); $i++)
+ for ($i = 0; ($row = $res->row_keyed($i)); $i++)
{
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits