Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
outils
question2answer
Commits
d7c19976
Commit
d7c19976
authored
Jul 30, 2020
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert some function calls to DbSelect
parent
3ac1100c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
24 additions
and
21 deletions
+24
-21
format.php
qa-include/app/format.php
+1
-1
limits.php
qa-include/app/limits.php
+3
-2
options.php
qa-include/app/options.php
+3
-2
page.php
qa-include/app/page.php
+13
-11
users.php
qa-include/app/users.php
+2
-2
DbSelect.php
qa-src/Database/DbSelect.php
+2
-3
No files found.
qa-include/app/format.php
View file @
d7c19976
...
...
@@ -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_r
esult
(
'favoritenonqs'
,
qa_db_user_favorite_non_qs_selectspec
(
$loginuserid
));
$favoritenonqs
=
qa_
service
(
'dbselect'
)
->
getPendingR
esult
(
'favoritenonqs'
,
qa_db_user_favorite_non_qs_selectspec
(
$loginuserid
));
foreach
(
$favoritenonqs
as
$favorite
)
{
switch
(
$favorite
[
'type'
])
{
...
...
qa-include/app/limits.php
View file @
d7c19976
...
...
@@ -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
]);
}
...
...
qa-include/app/options.php
View file @
d7c19976
...
...
@@ -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_r
esult
(
'options'
),
qa_db_get_pending_r
esult
(
'time'
),
$dbSelect
->
getPendingR
esult
(
'options'
),
$dbSelect
->
getPendingR
esult
(
'time'
),
));
}
...
...
qa-include/app/page.php
View file @
d7c19976
...
...
@@ -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_r
esult
(
'notices'
);
$notices
=
$dbSelect
->
getPendingR
esult
(
'notices'
);
foreach
(
$notices
as
$notice
)
$qa_content
[
'notices'
][]
=
qa_notice_form
(
$notice
[
'noticeid'
],
qa_viewer_html
(
$notice
[
'content'
],
$notice
[
'format'
]),
$notice
);
...
...
qa-include/app/users.php
View file @
d7c19976
...
...
@@ -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_r
esult
(
'loggedinuser'
,
qa_db_user_account_selectspec
(
$userid
,
true
));
$qa_cached_logged_in_user
=
qa_
service
(
'dbselect'
)
->
getPendingR
esult
(
'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_r
esult
(
'userlevels'
,
qa_db_user_levels_selectspec
(
qa_get_logged_in_userid
(),
true
));
return
qa_
service
(
'dbselect'
)
->
getPendingR
esult
(
'userlevels'
,
qa_db_user_levels_selectspec
(
qa_get_logged_in_userid
(),
true
));
}
...
...
qa-src/Database/DbSelect.php
View file @
d7c19976
...
...
@@ -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_r
esult()
* run again if its results are requested via
getPendingR
esult()
* @param string $pendingid
*/
public
function
flushPendingResult
(
$pendingid
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment