diff --git a/phpBB/develop/add_permissions.php b/phpBB/develop/add_permissions.php
index bc8c317c12..d83702f5ad 100644
--- a/phpBB/develop/add_permissions.php
+++ b/phpBB/develop/add_permissions.php
@@ -371,7 +371,7 @@ function mass_auth($ug_type, $forum_id, $ug_id, $acl_list, $setting)
switch ($sql_type)
{
case 'insert':
- switch (SQL_LAYER)
+ switch ($db->sql_layer)
{
case 'mysql':
case 'mysql4':
diff --git a/phpBB/develop/benchmark.php b/phpBB/develop/benchmark.php
index 2a88818975..5bbe6f53be 100644
--- a/phpBB/develop/benchmark.php
+++ b/phpBB/develop/benchmark.php
@@ -313,7 +313,7 @@ function make_post($new_topic_id, $forum_id, $user_id, $post_username, $text, $m
else
{
// Rollback
- if(SQL_LAYER == "mysql")
+ if($db->sql_layer == "mysql")
{
$sql = "DELETE FROM " . POSTS_TABLE . "
WHERE post_id = $new_post_id";
diff --git a/phpBB/develop/fill.php b/phpBB/develop/fill.php
index 3d01b2478e..2aee3d333f 100644
--- a/phpBB/develop/fill.php
+++ b/phpBB/develop/fill.php
@@ -12,7 +12,7 @@
// -------------------------------------------------------------
define('IN_PHPBB', true);
-$phpbb_root_path = './';
+$phpbb_root_path = './../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
@@ -22,13 +22,13 @@ header('Expires: 0');
ignore_user_abort(true);
// number of topics to create
-$num_topics = 5000000;
+$num_topics = 10000;
// number of topics to be generated per call
-$batch_size = 100000;
+$batch_size = 2000;
// max number of posts per topic
-$posts_per_topic = 500000;
+$posts_per_topic = 500;
// general vars
@@ -40,7 +40,7 @@ switch ($mode)
case 'generate':
$user_ids = $forum_ids = $topic_rows = array();
- $sql = 'SELECT user_id FROM ' . USERS_TABLE;
+ $sql = 'SELECT user_id FROM ' . USERS_TABLE . ' WHERE user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ') OR user_id = ' . ANONYMOUS;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
@@ -60,7 +60,7 @@ switch ($mode)
{
$db->sql_query('TRUNCATE TABLE ' . POSTS_TABLE);
$db->sql_query('TRUNCATE TABLE ' . TOPICS_TABLE);
- $db->sql_query('TRUNCATE TABLE ' . TOPICS_TABLE . '_prefetch');
+// $db->sql_query('TRUNCATE TABLE ' . TOPICS_TABLE . '_prefetch');
}
$db->sql_query('LOCK TABLES ' . POSTS_TABLE . ' WRITE, ' . TOPICS_TABLE . ' WRITE');
@@ -86,7 +86,7 @@ switch ($mode)
$rows = array();
$post_time = mt_rand(0, time());
- $num_posts = mt_rand(1, $posts_per_topic);
+ $num_posts = $posts_per_topic; //mt_rand(1, $posts_per_topic);
for ($i = 0; $i < $num_posts; ++$i)
{
$poster_id = $user_ids[array_rand($user_ids)];
@@ -108,18 +108,20 @@ switch ($mode)
if ($topic_id >= $num_topics)
{
- echo 'And now for something completely different...';
+ echo 'And now for something completely different...';
$db->sql_query('ANALYZE TABLES ' . TOPICS_TABLE . ', ' . POSTS_TABLE);
+ flush();
}
else
{
- echo 'To the next page... (' . $topic_id . '/' . $num_topics . ')';
+ echo 'To the next page... (' . $topic_id . '/' . $num_topics . ')';
+ flush();
}
break;
case 'sync':
- error_reporting(E_ALL);
+/* error_reporting(E_ALL);
$sync_all = TRUE;
if ($sync_all)
@@ -158,8 +160,11 @@ switch ($mode)
{
trigger_error('Done');
}
+ */
}
+$db->sql_close();
+
function rndm_username()
{
static $usernames;
diff --git a/phpBB/develop/merge_attachment_tables.php b/phpBB/develop/merge_attachment_tables.php
index 6e79515319..ae7fe57be4 100644
--- a/phpBB/develop/merge_attachment_tables.php
+++ b/phpBB/develop/merge_attachment_tables.php
@@ -48,7 +48,7 @@ $sql = "CREATE TABLE {$table_prefix}attachments
AND a.post_id = p.post_id";
$db->sql_query($sql);
-switch (SQL_LAYER)
+switch ($db->sql_layer)
{
case 'mysql':
case 'mysql4':
diff --git a/phpBB/develop/merge_post_tables.php b/phpBB/develop/merge_post_tables.php
index eb0cf2986a..3567a569c6 100644
--- a/phpBB/develop/merge_post_tables.php
+++ b/phpBB/develop/merge_post_tables.php
@@ -54,7 +54,7 @@ $sql = "CREATE TABLE {$table_prefix}posts
WHERE pt.post_id = p.post_id";
$db->sql_query($sql);
-switch (SQL_LAYER)
+switch ($db->sql_layer)
{
case 'mysql':
case 'mysql4':
@@ -150,7 +150,7 @@ while ($row = $db->sql_fetchrow($result))
}
$db->sql_freeresult($result);
-switch (SQL_LAYER)
+switch ($db->sql_layer)
{
case 'oracle':
$sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id
diff --git a/phpBB/includes/acp/acp_database.php b/phpBB/includes/acp/acp_database.php
index d4d4cf89b1..ccb1460c8a 100644
--- a/phpBB/includes/acp/acp_database.php
+++ b/phpBB/includes/acp/acp_database.php
@@ -133,7 +133,7 @@ class acp_database
$sql_data .= "# DATE : " . gmdate("d-m-Y H:i:s", $time) . " GMT\n";
$sql_data .= "#\n";
- switch (SQL_LAYER)
+ switch ($db->sql_layer)
{
case 'sqlite':
$sql_data .= "BEGIN TRANSACTION;\n";
@@ -151,7 +151,7 @@ class acp_database
break;
}
- if ($structure && SQL_LAYER == 'firebird')
+ if ($structure && $db->sql_layer == 'firebird')
{
$sql = 'SELECT RDB$FUNCTION_NAME, RDB$DESCRIPTION
FROM RDB$FUNCTIONS
@@ -181,7 +181,7 @@ class acp_database
// Get the table structure
if ($structure)
{
- switch (SQL_LAYER)
+ switch ($db->sql_layer)
{
case 'mysqli':
case 'mysql4':
@@ -224,27 +224,12 @@ class acp_database
}
$sql_data .= $this->get_table_structure($table_name);
}
- // We might wanna empty out all that junk :D
else
{
- switch (SQL_LAYER)
- {
- case 'mysqli':
- case 'mysql4':
- case 'mysql':
- case 'mssql':
- case 'mssql_odbc':
- case 'oracle':
- case 'postgres':
- case 'firebird':
- $sql_data .= 'TRUNCATE TABLE ' . $table_name . ";\n";
- break;
-
- case 'sqlite':
- $sql_data .= 'DELETE FROM ' . $table_name . ";\n";
- break;
- }
+ // We might wanna empty out all that junk :D
+ $sql_data .= (($db->sql_layer == 'sqlite') ? 'DELETE FROM ' : 'TRUNCATE TABLE ') . $table_name . ";\n";
}
+
// Now write the data for the first time. :)
if ($store == true)
{
@@ -270,7 +255,7 @@ class acp_database
{
$sql_data .= "\n";
- switch (SQL_LAYER)
+ switch ($db->sql_layer)
{
case 'mysqli':
@@ -1016,7 +1001,7 @@ class acp_database
}
}
- switch (SQL_LAYER)
+ switch ($db->sql_layer)
{
case 'sqlite':
case 'postgres':
@@ -1056,7 +1041,7 @@ class acp_database
default:
$tables = array();
- switch (SQL_LAYER)
+ switch ($db->sql_layer)
{
case 'sqlite':
$sql = "SELECT name
@@ -1247,13 +1232,13 @@ class acp_database
remove_remarks($data);
// SQLite gets improved performance when you shove all of these disk write queries at once :D
- if (SQL_LAYER == 'sqlite')
+ if ($db->sql_layer == 'sqlite')
{
$db->sql_query($data);
}
else
{
- switch (SQL_LAYER)
+ switch ($db->sql_layer)
{
case 'firebird':
$delim = ';;';
@@ -1351,7 +1336,7 @@ class acp_database
$sql_data = '';
- switch (SQL_LAYER)
+ switch ($db->sql_layer)
{
case 'mysqli':
case 'mysql4':
diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php
index cd63f26a1b..358c0cf3cd 100644
--- a/phpBB/includes/acp/acp_forums.php
+++ b/phpBB/includes/acp/acp_forums.php
@@ -210,34 +210,8 @@ class acp_forums
$db->sql_freeresult($result);
// Now insert the data
- switch (SQL_LAYER)
- {
- case 'mysql':
- case 'mysql4':
- case 'mysqli':
- if (sizeof($users_sql_ary))
- {
- $db->sql_query('INSERT INTO ' . ACL_USERS_TABLE . ' ' . $db->sql_build_array('MULTI_INSERT', $users_sql_ary));
- }
-
- if (sizeof($groups_sql_ary))
- {
- $db->sql_query('INSERT INTO ' . ACL_GROUPS_TABLE . ' ' . $db->sql_build_array('MULTI_INSERT', $groups_sql_ary));
- }
- break;
-
- default:
- foreach ($users_sql_ary as $ary)
- {
- $db->sql_query('INSERT INTO ' . ACL_USERS_TABLE . ' ' . $db->sql_build_array('INSERT', $ary));
- }
-
- foreach ($groups_sql_ary as $ary)
- {
- $db->sql_query('INSERT INTO ' . ACL_GROUPS_TABLE . ' ' . $db->sql_build_array('INSERT', $ary));
- }
- break;
- }
+ $db->sql_multi_insert(ACL_USERS_TABLE, $users_sql_ary);
+ $db->sql_multi_insert(ACL_GROUPS_TABLE, $groups_sql_ary);
}
$auth->acl_clear_prefetch();
@@ -1408,7 +1382,7 @@ class acp_forums
}
$db->sql_freeresult($result);
- switch (SQL_LAYER)
+ switch ($db->sql_layer)
{
case 'mysql4':
case 'mysqli':
diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php
index 600d596370..f4c869c40c 100644
--- a/phpBB/includes/acp/acp_groups.php
+++ b/phpBB/includes/acp/acp_groups.php
@@ -368,24 +368,7 @@ class acp_groups
$db->sql_freeresult($result);
// Now insert the data
- if (sizeof($groups_sql_ary))
- {
- switch (SQL_LAYER)
- {
- case 'mysql':
- case 'mysql4':
- case 'mysqli':
- $db->sql_query('INSERT INTO ' . ACL_GROUPS_TABLE . ' ' . $db->sql_build_array('MULTI_INSERT', $groups_sql_ary));
- break;
-
- default:
- foreach ($groups_sql_ary as $ary)
- {
- $db->sql_query('INSERT INTO ' . ACL_GROUPS_TABLE . ' ' . $db->sql_build_array('INSERT', $ary));
- }
- break;
- }
- }
+ $db->sql_multi_insert(ACL_GROUPS_TABLE, $groups_sql_ary);
$auth->acl_clear_prefetch();
}
diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php
index c4747a2e42..4636b067c2 100644
--- a/phpBB/includes/acp/acp_icons.php
+++ b/phpBB/includes/acp/acp_icons.php
@@ -311,7 +311,7 @@ class acp_icons
// The user has already selected a smilies_pak file
if ($current == 'delete')
{
- $db->sql_query(((SQL_LAYER != 'sqlite') ? 'TRUNCATE TABLE ' : 'DELETE FROM ') . $table);
+ $db->sql_query((($db->sql_layer != 'sqlite') ? 'TRUNCATE TABLE ' : 'DELETE FROM ') . $table);
switch ($mode)
{
diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php
index d8e8cdf192..4bd230458b 100644
--- a/phpBB/includes/acp/acp_main.php
+++ b/phpBB/includes/acp/acp_main.php
@@ -149,7 +149,7 @@ class acp_main
break;
case 'db_track':
- $db->sql_query(((SQL_LAYER != 'sqlite') ? 'TRUNCATE TABLE ' : 'DELETE FROM ') . TOPICS_POSTED_TABLE);
+ $db->sql_query((($db->sql_layer != 'sqlite') ? 'TRUNCATE TABLE ' : 'DELETE FROM ') . TOPICS_POSTED_TABLE);
// This can get really nasty... therefore we only do the last six months
$get_from_time = time() - (6 * 4 * 7 * 24 * 60 * 60);
@@ -204,24 +204,7 @@ class acp_main
}
unset($posted);
- if (sizeof($sql_ary))
- {
- switch (SQL_LAYER)
- {
- case 'mysql':
- case 'mysql4':
- case 'mysqli':
- $db->sql_query('INSERT INTO ' . TOPICS_POSTED_TABLE . ' ' . $db->sql_build_array('MULTI_INSERT', $sql_ary));
- break;
-
- default:
- foreach ($sql_ary as $ary)
- {
- $db->sql_query('INSERT INTO ' . TOPICS_POSTED_TABLE . ' ' . $db->sql_build_array('INSERT', $ary));
- }
- break;
- }
- }
+ $db->sql_multi_insert(TOPICS_POSTED_TABLE, $sql_ary);
}
add_log('admin', 'LOG_RESYNC_POST_MARKING');
diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php
index e5b998f535..4862d3ead0 100644
--- a/phpBB/includes/acp/acp_profile.php
+++ b/phpBB/includes/acp/acp_profile.php
@@ -107,7 +107,7 @@ class acp_profile
$db->sql_query('DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . " WHERE field_id = $field_id");
$db->sql_query('DELETE FROM ' . PROFILE_LANG_TABLE . " WHERE field_id = $field_id");
- switch (SQL_LAYER)
+ switch ($db->sql_layer)
{
case 'sqlite':
$sql = "SELECT sql
@@ -1236,7 +1236,7 @@ class acp_profile
{
global $db;
- switch (SQL_LAYER)
+ switch ($db->sql_layer)
{
case 'mysql':
case 'mysql4':
diff --git a/phpBB/includes/acp/acp_reasons.php b/phpBB/includes/acp/acp_reasons.php
index abf554d824..0dd62b5e22 100644
--- a/phpBB/includes/acp/acp_reasons.php
+++ b/phpBB/includes/acp/acp_reasons.php
@@ -202,7 +202,7 @@ class acp_reasons
$other_reason_id = (int) $db->sql_fetchfield('reason_id');
$db->sql_freeresult($result);
- switch (SQL_LAYER)
+ switch ($db->sql_layer)
{
// The ugly one!
case 'mysqli':
diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php
index e029fb54b9..94d24e6505 100644
--- a/phpBB/includes/acp/acp_users.php
+++ b/phpBB/includes/acp/acp_users.php
@@ -1040,7 +1040,7 @@ class acp_users
// Update Custom Fields
if (sizeof($cp_data))
{
- switch (SQL_LAYER)
+ switch ($db->sql_layer)
{
case 'oracle':
case 'firebird':
@@ -1944,7 +1944,7 @@ class acp_users
FROM ' . ACL_OPTIONS_TABLE . "
WHERE auth_option LIKE '%\_'";
- if (SQL_LAYER == 'mssql' || SQL_LAYER == 'mssql_odbc')
+ if ($db->sql_layer == 'mssql' || $db->sql_layer == 'mssql_odbc')
{
$sql .= " ESCAPE '\\'";
}
@@ -1964,7 +1964,7 @@ class acp_users
FROM ' . ACL_OPTIONS_TABLE . "
WHERE auth_option LIKE '%\_'";
- if (SQL_LAYER == 'mssql' || SQL_LAYER == 'mssql_odbc')
+ if ($db->sql_layer == 'mssql' || $db->sql_layer == 'mssql_odbc')
{
$sql .= " ESCAPE '\\'";
}
diff --git a/phpBB/includes/acp/auth.php b/phpBB/includes/acp/auth.php
index 36fa5dbcea..436e3f017b 100644
--- a/phpBB/includes/acp/auth.php
+++ b/phpBB/includes/acp/auth.php
@@ -724,24 +724,7 @@ class auth_admin extends auth
}
}
- if (sizeof($sql_ary))
- {
- switch (SQL_LAYER)
- {
- case 'mysql':
- case 'mysql4':
- case 'mysqli':
- $db->sql_query('INSERT INTO ' . ACL_OPTIONS_TABLE . ' ' . $db->sql_build_array('MULTI_INSERT', $sql_ary));
- break;
-
- default:
- foreach ($sql_ary as $ary)
- {
- $db->sql_query('INSERT INTO ' . ACL_OPTIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $ary));
- }
- break;
- }
- }
+ $db->sql_multi_insert(ACL_OPTIONS_TABLE, $sql_ary);
$cache->destroy('acl_options');
$this->acl_clear_prefetch();
@@ -874,24 +857,7 @@ class auth_admin extends auth
}
}
- if (sizeof($sql_ary))
- {
- switch (SQL_LAYER)
- {
- case 'mysql':
- case 'mysql4':
- case 'mysqli':
- $db->sql_query("INSERT INTO $table " . $db->sql_build_array('MULTI_INSERT', $sql_ary));
- break;
-
- default:
- foreach ($sql_ary as $ary)
- {
- $db->sql_query("INSERT INTO $table " . $db->sql_build_array('INSERT', $ary));
- }
- break;
- }
- }
+ $db->sql_multi_insert($table, $sql_ary);
if ($clear_prefetch)
{
@@ -956,21 +922,8 @@ class auth_admin extends auth
WHERE role_id = ' . $role_id;
$db->sql_query($sql);
- switch (SQL_LAYER)
- {
- case 'mysql':
- case 'mysql4':
- case 'mysqli':
- $db->sql_query('INSERT INTO ' . ACL_ROLES_DATA_TABLE . ' ' . $db->sql_build_array('MULTI_INSERT', $sql_ary));
- break;
-
- default:
- foreach ($sql_ary as $ary)
- {
- $db->sql_query('INSERT INTO ' . ACL_ROLES_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $ary));
- }
- break;
- }
+ // Now insert the new values
+ $db->sql_multi_insert(ACL_ROLES_DATA_TABLE, $sql_ary);
$this->acl_clear_prefetch();
}
@@ -1010,7 +963,7 @@ class auth_admin extends auth
$sql = 'SELECT auth_option, auth_option_id
FROM ' . ACL_OPTIONS_TABLE . "
WHERE auth_option LIKE '" . $db->sql_escape(str_replace('_', "\_", $permission_type)) . "%'";
- $sql .= (SQL_LAYER == 'mssql' || SQL_LAYER == 'mssql_odbc') ? " ESCAPE '\\'" : '';
+ $sql .= ($db->sql_layer == 'mssql' || $db->sql_layer == 'mssql_odbc') ? " ESCAPE '\\'" : '';
$result = $db->sql_query($sql);
diff --git a/phpBB/includes/auth.php b/phpBB/includes/auth.php
index 8ff18bd4ec..ffce18ffb7 100644
--- a/phpBB/includes/auth.php
+++ b/phpBB/includes/auth.php
@@ -802,7 +802,7 @@ class auth
if (strpos($auth_options, '_') !== false)
{
$sql_opts = "AND $key LIKE '" . $db->sql_escape(str_replace('_', "\_", $auth_options)) . "'";
- $sql_escape = (SQL_LAYER == 'mssql' || SQL_LAYER == 'mssql_odbc') ? " ESCAPE '\\'" : '';
+ $sql_escape = ($db->sql_layer == 'mssql' || $db->sql_layer == 'mssql_odbc') ? " ESCAPE '\\'" : '';
}
else
{
@@ -848,7 +848,7 @@ class auth
if ($is_underline)
{
- $sql_escape = (SQL_LAYER == 'mssql' || SQL_LAYER == 'mssql_odbc') ? " ESCAPE '\\'" : '';
+ $sql_escape = ($db->sql_layer == 'mssql' || $db->sql_layer == 'mssql_odbc') ? " ESCAPE '\\'" : '';
}
}
}
diff --git a/phpBB/includes/cache.php b/phpBB/includes/cache.php
index 2ac8298047..8d6e17a8df 100644
--- a/phpBB/includes/cache.php
+++ b/phpBB/includes/cache.php
@@ -266,7 +266,7 @@ class cache extends acm
{
global $db;
- switch (SQL_LAYER)
+ switch ($db->sql_layer)
{
case 'mssql':
case 'mssql_odbc':
diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php
index 732ecdfed6..cbeb3dca24 100644
--- a/phpBB/includes/db/dbal.php
+++ b/phpBB/includes/db/dbal.php
@@ -38,6 +38,11 @@ class dbal
// Holding the last sql query on sql error
var $sql_error_sql = '';
+ /**
+ * Current sql layer
+ */
+ var $sql_layer = '';
+
/**
* Constructor
*/
@@ -48,6 +53,10 @@ class dbal
'normal' => 0,
'total' => 0,
);
+
+ // Fill default sql layer based on the class being called.
+ // This can be changed by the specified layer itself later if needed.
+ $this->sql_layer = substr(get_class($this), 5);
}
/**
@@ -243,6 +252,12 @@ class dbal
$ary = array();
foreach ($assoc_ary as $id => $sql_ary)
{
+ // If by accident the sql array is only one-dimensional we build a normal insert statement
+ if (!is_array($sql_ary))
+ {
+ return $this->sql_build_array('INSERT', $assoc_ary);
+ }
+
$values = array();
foreach ($sql_ary as $key => $var)
{
@@ -266,6 +281,10 @@ class dbal
return $query;
}
+ /**
+ * Build IN, NOT IN, = and <> sql comparison string.
+ * @access public
+ */
function sql_in_set($field, $array, $negate = false)
{
if (!sizeof($array))
@@ -295,6 +314,47 @@ class dbal
}
}
+ /**
+ * Run more than one insert statement.
+ *
+ * @param $sql_ary array multi-dimensional array holding the statement data.
+ * @param $table string table name to run the statements on
+ *
+ * @return bool false if no statements were executed.
+ * @access public
+ */
+ function sql_multi_insert($table, &$sql_ary)
+ {
+ if (!sizeof($sql_ary))
+ {
+ return false;
+ }
+
+ switch ($this->sql_layer)
+ {
+ case 'mysql':
+ case 'mysql4':
+ case 'mysqli':
+ case 'sqlite':
+ $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('MULTI_INSERT', $sql_ary));
+ break;
+
+ default:
+ foreach ($sql_ary as $ary)
+ {
+ if (!is_array($ary))
+ {
+ return false;
+ }
+
+ $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $ary));
+ }
+ break;
+ }
+
+ return true;
+ }
+
/**
* Function for validating values
* @access private
@@ -392,7 +452,7 @@ class dbal
if (!$this->return_on_error)
{
- $message = 'SQL ERROR [ ' . SQL_LAYER . ' ]
' . $error['message'] . ' [' . $error['code'] . ']';
+ $message = 'SQL ERROR [ ' . $db->sql_layer . ' ]
' . $error['message'] . ' [' . $error['code'] . ']';
// Show complete SQL error and path to administrators only
// Additionally show complete error on installation or if extended debug mode is enabled
@@ -491,7 +551,7 @@ class dbal
Page generated in ' . round($totaltime, 4) . " seconds with {$this->num_queries['normal']} queries" . (($this->num_queries['cached']) ? " + {$this->num_queries['cached']} " . (($this->num_queries['cached'] == 1) ? 'query' : 'queries') . ' returning data from cache' : '') . '
-Time spent on ' . SQL_LAYER . ' queries: ' . round($this->sql_time, 5) . 's | Time spent on PHP: ' . round($totaltime - $this->sql_time, 5) . 's
+Time spent on ' . $db->sql_layer . ' queries: ' . round($this->sql_time, 5) . 's | Time spent on PHP: ' . round($totaltime - $this->sql_time, 5) . 's
::
+
:: sql_layer; ?>
sql_layer)
{
case 'mysql':
+ case 'mysqli':
case 'mysql4':
$sql = 'OPTIMIZE TABLE ' . $table_prefix . 'auth_access, ' . $table_prefix . 'banlist, ' . $table_prefix . 'categories, ' . $table_prefix . 'config, ' . $table_prefix . 'disallow, ' . $table_prefix . 'forum_prune, ' . $table_prefix . 'forums, ' . $table_prefix . 'groups, ' . $table_prefix . 'posts, ' . $table_prefix . 'posts_text, ' . $table_prefix . 'privmsgs, ' . $table_prefix . 'privmsgs_text, ' . $table_prefix . 'ranks, ' . $table_prefix . 'search_results, ' . $table_prefix . 'search_wordlist, ' . $table_prefix . 'search_wordmatch, ' . $table_prefix . 'sessions_keys' . $table_prefix . 'smilies, ' . $table_prefix . 'themes, ' . $table_prefix . 'themes_name, ' . $table_prefix . 'topics, ' . $table_prefix . 'topics_watch, ' . $table_prefix . 'user_group, ' . $table_prefix . 'users, ' . $table_prefix . 'vote_desc, ' . $table_prefix . 'vote_results, ' . $table_prefix . 'vote_voters, ' . $table_prefix . 'words';
_sql($sql, $errored, $error_ary);
diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php
index 4d52ca7a9c..324a6f432b 100755
--- a/phpBB/install/install_install.php
+++ b/phpBB/install/install_install.php
@@ -997,7 +997,7 @@ class install_install extends module
// If mysql is chosen, we need to adjust the schema filename slightly to reflect the correct version. ;)
if ($dbms == 'mysql')
{
- if (SQL_LAYER == 'mysql4' && version_compare($db->mysql_version, '4.1.3', '>='))
+ if ($db->sql_layer == 'mysql4' && version_compare($db->mysql_version, '4.1.3', '>='))
{
$this->available_dbms[$dbms]['SCHEMA'] .= '_41';
}
diff --git a/phpBB/search.php b/phpBB/search.php
index 79a3fb4565..73c363bcc6 100644
--- a/phpBB/search.php
+++ b/phpBB/search.php
@@ -970,7 +970,7 @@ $template->assign_vars(array(
);
// Can't do comparisons w/ TEXT on MSSQL, CAST is good enough
-switch (SQL_LAYER)
+switch ($db->sql_layer)
{
case 'mssql':
case 'mssql_odbc':
diff --git a/phpBB/viewonline.php b/phpBB/viewonline.php
index 829bdc59fe..3edf7090d6 100644
--- a/phpBB/viewonline.php
+++ b/phpBB/viewonline.php
@@ -87,7 +87,7 @@ $guest_counter = 0;
// Get number of online guests (if we do not display them)
if (!$show_guests)
{
- switch (SQL_LAYER)
+ switch ($db->sql_layer)
{
case 'sqlite':
$sql = 'SELECT COUNT(session_ip) as num_guests
@@ -104,6 +104,7 @@ if (!$show_guests)
FROM ' . SESSIONS_TABLE . '
WHERE session_user_id = ' . ANONYMOUS . '
AND session_time >= ' . (time() - ($config['load_online_time'] * 60));
+ break;
}
$result = $db->sql_query($sql);
$guest_counter = (int) $db->sql_fetchfield('num_guests');