Commit d7c19976 by Scott

Convert some function calls to DbSelect

parent 3ac1100c
......@@ -156,7 +156,7 @@ function qa_get_favorite_non_qs_map()
require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR . 'util/string.php';
$favoritenonqs = qa_db_get_pending_result('favoritenonqs', qa_db_user_favorite_non_qs_selectspec($loginuserid));
$favoritenonqs = qa_service('dbselect')->getPendingResult('favoritenonqs', qa_db_user_favorite_non_qs_selectspec($loginuserid));
foreach ($favoritenonqs as $favorite) {
switch ($favorite['type']) {
......
......@@ -44,8 +44,9 @@ define('QA_LIMIT_WALL_POSTS', 'W');
*/
function qa_user_limits_remaining($action)
{
$userlimits = qa_db_get_pending_result('userlimits', qa_db_user_limits_selectspec(qa_get_logged_in_userid()));
$iplimits = qa_db_get_pending_result('iplimits', qa_db_ip_limits_selectspec(qa_remote_ip_address()));
$dbSelect = qa_service('dbselect');
$userlimits = $dbSelect->getPendingResult('userlimits', qa_db_user_limits_selectspec(qa_get_logged_in_userid()));
$iplimits = $dbSelect->getPendingResult('iplimits', qa_db_ip_limits_selectspec(qa_remote_ip_address()));
return qa_limits_calc_remaining($action, @$userlimits[$action], @$iplimits[$action]);
}
......
......@@ -58,9 +58,10 @@ function qa_get_options($names)
if (!$qa_options_loaded) {
require_once QA_INCLUDE_DIR . 'db/selects.php';
$dbSelect = qa_service('dbselect');
qa_load_options_results(array(
qa_db_get_pending_result('options'),
qa_db_get_pending_result('time'),
$dbSelect->getPendingResult('options'),
$dbSelect->getPendingResult('time'),
));
}
......
......@@ -40,20 +40,21 @@ function qa_page_queue_pending()
qa_preload_options();
$loginuserid = qa_get_logged_in_userid();
$dbSelect = qa_service('dbselect');
if (isset($loginuserid)) {
if (!QA_FINAL_EXTERNAL_USERS)
qa_db_queue_pending_select('loggedinuser', qa_db_user_account_selectspec($loginuserid, true));
$dbSelect->queuePending('loggedinuser', qa_db_user_account_selectspec($loginuserid, true));
qa_db_queue_pending_select('notices', qa_db_user_notices_selectspec($loginuserid));
qa_db_queue_pending_select('favoritenonqs', qa_db_user_favorite_non_qs_selectspec($loginuserid));
qa_db_queue_pending_select('userlimits', qa_db_user_limits_selectspec($loginuserid));
qa_db_queue_pending_select('userlevels', qa_db_user_levels_selectspec($loginuserid, true));
$dbSelect->queuePending('notices', qa_db_user_notices_selectspec($loginuserid));
$dbSelect->queuePending('favoritenonqs', qa_db_user_favorite_non_qs_selectspec($loginuserid));
$dbSelect->queuePending('userlimits', qa_db_user_limits_selectspec($loginuserid));
$dbSelect->queuePending('userlevels', qa_db_user_levels_selectspec($loginuserid, true));
}
qa_db_queue_pending_select('iplimits', qa_db_ip_limits_selectspec(qa_remote_ip_address()));
qa_db_queue_pending_select('navpages', qa_db_pages_selectspec(array('B', 'M', 'O', 'F')));
qa_db_queue_pending_select('widgets', qa_db_widgets_selectspec());
$dbSelect->queuePending('iplimits', qa_db_ip_limits_selectspec(qa_remote_ip_address()));
$dbSelect->queuePending('navpages', qa_db_pages_selectspec(array('B', 'M', 'O', 'F')));
$dbSelect->queuePending('widgets', qa_db_widgets_selectspec());
}
......@@ -516,8 +517,9 @@ function qa_content_prepare($voting = false, $categoryids = array())
$request = qa_request();
$requestlower = qa_request();
$navpages = qa_db_get_pending_result('navpages');
$widgets = qa_db_get_pending_result('widgets');
$dbSelect = qa_service('dbselect');
$navpages = $dbSelect->getPendingResult('navpages');
$widgets = $dbSelect->getPendingResult('widgets');
if (!is_array($categoryids)) {
// accept old-style parameter
......@@ -789,7 +791,7 @@ function qa_content_prepare($voting = false, $categoryids = array())
}
}
$notices = qa_db_get_pending_result('notices');
$notices = $dbSelect->getPendingResult('notices');
foreach ($notices as $notice)
$qa_content['notices'][] = qa_notice_form($notice['noticeid'], qa_viewer_html($notice['content'], $notice['format']), $notice);
......
......@@ -456,7 +456,7 @@ if (QA_FINAL_EXTERNAL_USERS) {
if (isset($userid)) {
require_once QA_INCLUDE_DIR . 'db/selects.php';
$qa_cached_logged_in_user = qa_db_get_pending_result('loggedinuser', qa_db_user_account_selectspec($userid, true));
$qa_cached_logged_in_user = qa_service('dbselect')->getPendingResult('loggedinuser', qa_db_user_account_selectspec($userid, true));
// If the site is configured to share the ^users table then there might not be a record in the
// ^userpoints table so this creates it
......@@ -813,7 +813,7 @@ function qa_get_logged_in_levels()
{
require_once QA_INCLUDE_DIR . 'db/selects.php';
return qa_db_get_pending_result('userlevels', qa_db_user_levels_selectspec(qa_get_logged_in_userid(), true));
return qa_service('dbselect')->getPendingResult('userlevels', qa_db_user_levels_selectspec(qa_get_logged_in_userid(), true));
}
......
......@@ -19,7 +19,6 @@
namespace Q2A\Database;
use Q2A\Storage\CacheFactory;
use Q2A\Util\Set;
/*
The selectspec array can contain the elements below. See db/selects.php for lots of examples.
......@@ -41,7 +40,7 @@ use Q2A\Util\Set;
'source' => Any SQL after FROM, including table names, JOINs, GROUP BY, ORDER BY, WHERE, etc... (required)
'arguments' => Substitutions in order for $s and #s in the query, applied in qa_db_apply_sub() above (required)
'arguments' => Substitutions in order for ?s in the query, applied in DbConnection->query()
'arraykey' => Name of column to use for keys of the outer-level returned array, instead of numbers by default
......@@ -325,7 +324,7 @@ class DbSelect
/**
* Remove the results of queued SELECT query identified by $pendingid if it has already been run. This means it will
* run again if its results are requested via qa_db_get_pending_result()
* run again if its results are requested via getPendingResult()
* @param string $pendingid
*/
public function flushPendingResult($pendingid)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment