Skip to content
Snippets Groups Projects
Commit ac431a8d authored by Patrick Dawkins's avatar Patrick Dawkins
Browse files

Replaced some db_selects with db_querys

parent ee33937b
No related branches found
No related tags found
No related merge requests found
...@@ -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) {
......
...@@ -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;
} }
......
...@@ -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')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment