Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
election
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
election
Commits
ac431a8d
Commit
ac431a8d
authored
13 years ago
by
Patrick Dawkins
Browse files
Options
Downloads
Patches
Plain Diff
Replaced some db_selects with db_querys
parent
ee33937b
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
election-candidate.pages.inc
+4
-5
4 additions, 5 deletions
election-candidate.pages.inc
election-post.admin.inc
+1
-4
1 addition, 4 deletions
election-post.admin.inc
election.module
+4
-15
4 additions, 15 deletions
election.module
with
9 additions
and
24 deletions
election-candidate.pages.inc
+
4
−
5
View file @
ac431a8d
...
@@ -41,11 +41,10 @@ function election_nomination_form($form, &$form_state, $election, $candidate) {
...
@@ -41,11 +41,10 @@ function election_nomination_form($form, &$form_state, $election, $candidate) {
$posts_name
=
_election_get_posts_name
(
$election
->
type
);
$posts_name
=
_election_get_posts_name
(
$election
->
type
);
$posts_query
=
db_select
(
'election_post'
,
'ep'
);
$post_ids
=
db_query
(
$posts_query
->
fields
(
'ep'
,
array
(
'post_id'
));
'SELECT post_id FROM {election_post} WHERE election_id = :eid'
,
$posts_query
->
condition
(
'election_id'
,
$election
->
election_id
);
array
(
':eid'
=>
$election
->
election_id
)
$posts_result
=
$posts_query
->
execute
();
)
->
fetchCol
();
$post_ids
=
$posts_result
->
fetchCol
();
$posts
=
election_post_load_multiple
(
$post_ids
);
$posts
=
election_post_load_multiple
(
$post_ids
);
$post_options
=
array
();
$post_options
=
array
();
foreach
(
$posts
as
$post
)
{
foreach
(
$posts
as
$post
)
{
...
...
This diff is collapsed.
Click to expand it.
election-post.admin.inc
+
1
−
4
View file @
ac431a8d
...
@@ -78,10 +78,7 @@ function election_post_form($form, &$form_state, $election, $post) {
...
@@ -78,10 +78,7 @@ function election_post_form($form, &$form_state, $election, $post) {
$post
->
electorates
=
array
();
$post
->
electorates
=
array
();
if
(
!
$post
->
is_new
)
{
if
(
!
$post
->
is_new
)
{
$result
=
db_select
(
'election_post_electorate'
,
'epe'
)
$result
=
db_query
(
'SELECT electorate_id FROM {election_post_electorate} WHERE post_id = :pid'
,
array
(
':pid'
=>
$post
->
post_id
));
->
fields
(
'epe'
,
array
(
'electorate_id'
))
->
condition
(
'post_id'
,
$post
->
post_id
)
->
execute
();
while
(
$row
=
$result
->
fetchAssoc
())
{
while
(
$row
=
$result
->
fetchAssoc
())
{
$post
->
electorates
[
$row
[
'electorate_id'
]]
=
1
;
$post
->
electorates
[
$row
[
'electorate_id'
]]
=
1
;
}
}
...
...
This diff is collapsed.
Click to expand it.
election.module
+
4
−
15
View file @
ac431a8d
...
@@ -300,10 +300,7 @@ function election_load($election_id = NULL) {
...
@@ -300,10 +300,7 @@ function election_load($election_id = NULL) {
* @return array
* @return array
*/
*/
function
election_electorates
()
{
function
election_electorates
()
{
$query
=
db_select
(
'election_electorate'
,
'ee'
);
$result
=
db_query
(
'SELECT * FROM {election_electorate} ORDER BY name'
);
$query
->
fields
(
'ee'
);
$query
->
orderBy
(
'name'
);
$result
=
$query
->
execute
();
$electorates
=
array
();
$electorates
=
array
();
...
@@ -389,21 +386,13 @@ function _election_uninstall_code_electorates() {
...
@@ -389,21 +386,13 @@ function _election_uninstall_code_electorates() {
$code_electorates
=
_election_get_code_electorates
();
$code_electorates
=
_election_get_code_electorates
();
$transaction
=
db_transaction
();
$transaction
=
db_transaction
();
try
{
try
{
$db_electorates
=
db_select
(
'election_electorate'
,
'ee'
)
$db_electorates
=
db_query
(
'SELECT electorate_id, machine_name FROM {election_electorate} WHERE locked = 1'
);
->
fields
(
'ee'
,
array
(
'electorate_id'
,
'machine_name'
))
->
condition
(
'locked'
,
'1'
)
->
execute
();
while
(
$db_electorate
=
$db_electorates
->
fetchAssoc
())
{
while
(
$db_electorate
=
$db_electorates
->
fetchAssoc
())
{
if
(
isset
(
$code_electorates
[
$db_electorate
[
'machine_name'
]]))
{
if
(
isset
(
$code_electorates
[
$db_electorate
[
'machine_name'
]]))
{
continue
;
continue
;
}
}
$assigned
=
db_select
(
'election_post_electorate'
,
'epe'
)
$assigned
=
db_query
(
'SELECT 1 FROM {election_post_electorate} WHERE electorate_id = :eid LIMIT 1'
,
array
(
':eid'
,
$db_electorate
[
'electorate_id'
]));
->
fields
(
'epe'
)
if
(
$assigned
->
rowCount
())
{
->
condition
(
'electorate_id'
,
$db_electorate
[
'electorate_id'
])
->
range
(
0
,
1
)
->
execute
()
->
fetchCol
();
if
(
count
(
$assigned
))
{
continue
;
continue
;
}
}
db_delete
(
'election_electorate'
)
db_delete
(
'election_electorate'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment