diff options
author | Paul S. Owen <psotfx@users.sourceforge.net> | 2003-04-17 22:59:51 +0000 |
---|---|---|
committer | Paul S. Owen <psotfx@users.sourceforge.net> | 2003-04-17 22:59:51 +0000 |
commit | a79524cb337ca5e467e5a1a9a5e7f8d756698f98 (patch) | |
tree | 4c59fd9ff40d4d21dbd78a7f1bda6ab279683ea5 | |
parent | e93d9d23f22ff0f3e4a64abd3181babdf19a7f1b (diff) | |
download | forums-a79524cb337ca5e467e5a1a9a5e7f8d756698f98.tar forums-a79524cb337ca5e467e5a1a9a5e7f8d756698f98.tar.gz forums-a79524cb337ca5e467e5a1a9a5e7f8d756698f98.tar.bz2 forums-a79524cb337ca5e467e5a1a9a5e7f8d756698f98.tar.xz forums-a79524cb337ca5e467e5a1a9a5e7f8d756698f98.zip |
Reduce (only a tad but still) the potential number of queries done when updating permissions
git-svn-id: file:///svn/phpbb/trunk@3878 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r-- | phpBB/includes/functions_admin.php | 68 |
1 files changed, 55 insertions, 13 deletions
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index de282e2570..bfae85bd92 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -1663,34 +1663,76 @@ if (class_exists(auth)) switch ($setting) { case ACL_UNSET: - $sql_ary[] = "DELETE FROM $table - WHERE forum_id = $forum - AND auth_option_id = $auth_option_id - AND $id_field = $ug_id"; + if (isset($cur_auth[$forum][$auth_option_id])) + { + $sql_ary['delete'][] = "DELETE FROM $table + WHERE forum_id = $forum + AND auth_option_id = $auth_option_id + AND $id_field = $ug_id"; + } break; default: - if (isset($cur_auth[$forum][$auth_option_id]) && $cur_auth[$forum][$auth_option_id] != $setting) + if (!isset($cur_auth[$forum][$auth_option_id])) { - $sql_ary[] = "UPDATE " . $table . " + $sql_ary['insert'][] = "$ug_id, $forum, $auth_option_id, $setting"; + } + else if ($cur_auth[$forum][$auth_option_id] != $setting) + { + $sql_ary['update'][] = "UPDATE " . $table . " SET auth_setting = $setting WHERE $id_field = $ug_id AND forum_id = $forum AND auth_option_id = $auth_option_id"; } - else if (!isset($cur_auth[$forum][$auth_option_id])) - { - $sql_ary[] = "INSERT INTO $table ($id_field, forum_id, auth_option_id, auth_setting) - VALUES ($ug_id, $forum, $auth_option_id, $setting)"; - } } } } unset($cur_auth); - foreach ($sql_ary as $sql) + $sql = ''; + foreach ($sql_ary as $sql_type => $sql_subary) { - $result = $db->sql_query($sql); + switch ($sql_type) + { + case 'insert': + switch (SQL_LAYER) + { + case 'mysql': + case 'mysql4': + $sql = implode(', ', preg_replace('#^(.*?)$#', '(\1)', $sql_subary)); + break; + + case 'mssql': + $sql = implode(' UNION ALL ', preg_replace('#^(.*?)$#', 'SELECT \1', $sql_subary)); + break; + + default: + foreach ($sql_subary as $sql) + { + $sql = "INSERT INTO $table ($id_field, forum_id, auth_option_id, auth_setting) VALUES ($sql)"; + $db->sql_query($sql); + $sql = ''; + } + } + + if ($sql != '') + { + $sql = "INSERT INTO $table ($id_field, forum_id, auth_option_id, auth_setting) VALUES $sql"; + $db->sql_query($sql); + } + break; + + case 'update': + case 'delete': + foreach ($sql_subary as $sql) + { + $result = $db->sql_query($sql); + $sql = ''; + } + break; + } + unset($sql_ary[$sql_type]); } unset($sql_ary); |