summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2008-09-26 23:30:20 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2008-09-26 23:30:20 +0000
commit152213c8736b603cbd96fce4425142e87a96992d (patch)
tree56774518ed936c010bc07452477b6fc533dc1a86
parent40e2b5211621ea73cd1ff27d50c5cc2124f15342 (diff)
downloadbrdo-152213c8736b603cbd96fce4425142e87a96992d.tar.gz
brdo-152213c8736b603cbd96fce4425142e87a96992d.tar.bz2
#313152 by Crell and Rob Loach: DBTNG clean-up of batch.inc
-rw-r--r--includes/batch.inc23
1 files changed, 16 insertions, 7 deletions
diff --git a/includes/batch.inc b/includes/batch.inc
index 611875154..ad5630368 100644
--- a/includes/batch.inc
+++ b/includes/batch.inc
@@ -11,14 +11,18 @@
function _batch_page() {
$batch =& batch_get();
- // Retrieve the current state of batch from db.
- if (isset($_REQUEST['id']) && $data = db_result(db_query("SELECT batch FROM {batch} WHERE bid = %d AND token = '%s'", $_REQUEST['id'], drupal_get_token($_REQUEST['id'])))) {
- $batch = unserialize($data);
- }
- else {
+ if (!isset($_REQUEST['id'])) {
return FALSE;
}
+ // Retrieve the current state of batch from db.
+ $batch = db_query("SELECT batch FROM {batch} WHERE bid = :bid AND token = :token", array(
+ ':bid' => $_REQUEST['id'],
+ ':token' => drupal_get_token($_REQUEST['id']))
+ )->fetchField();
+
+ $batch = unserialize($batch);
+
// Register database update for end of processing.
register_shutdown_function('_batch_shutdown');
@@ -314,7 +318,9 @@ function _batch_finished() {
// Cleanup the batch table and unset the global $batch variable.
if ($batch['progressive']) {
- db_query("DELETE FROM {batch} WHERE bid = %d", $batch['id']);
+ db_delete('batch')
+ ->condition('bid', $batch['id'])
+ ->execute();
}
$_batch = $batch;
$batch = NULL;
@@ -358,6 +364,9 @@ function _batch_finished() {
*/
function _batch_shutdown() {
if ($batch = batch_get()) {
- db_query("UPDATE {batch} SET batch = '%s' WHERE bid = %d", serialize($batch), $batch['id']);
+ db_update('batch')
+ ->fields(array('batch' => serialize($batch)))
+ ->condition('bid', $batch['id'])
+ ->execute();
}
}