[datapress] r166 committed - attempt to wipe stuff clean

0 views
Skip to first unread message

codesite...@google.com

unread,
May 11, 2011, 4:03:47 PM5/11/11
to datapres...@googlegroups.com
Revision: 166
Author: edward.benson
Date: Wed May 11 13:03:00 2011
Log: attempt to wipe stuff clean
http://code.google.com/p/datapress/source/detail?r=166

Modified:
/trunk/plugin/wp-exhibit-geocoder.php

=======================================
--- /trunk/plugin/wp-exhibit-geocoder.php Wed May 11 12:45:27 2011
+++ /trunk/plugin/wp-exhibit-geocoder.php Wed May 11 13:03:00 2011
@@ -5,14 +5,27 @@
// Perform the geocoding for a batch of items. Returns false if
// $datum_ids and $addresses are a different size.
static function batch_add($exhibit_id, $address_field, $datum_ids,
$addresses) {
- if(count($datum_ids) == count($addresses)) {
- for($i = 0; $i < count($datum_ids); $i++) {
- WpExhibitGeocoder::lookup($exhibit_id, $address_field, $datum_ids[$i],
$addresses[$i]);
- }
- return true;
- } else {
- return false;
- }
+ /*
+ * Delete everything that isn't one of datum_ids and is associated
with exhibit_id,address_field
+ */
+ $sql = "DELETE FROM $table WHERE exhibit_id = %d AND addressField
= %s AND datum_id NOT IN (%s);";
+ $list_of_ids = array();
+ for ($i =0; i<count($datum_ids); $i++) {
+ $list_of_ids[$i] = "'" . $datum_ids[$i] . "'";
+ }
+ $theList = join(", ", $list_of_ids);
+
+ $query = $wpdb->prepare($sql, $exhibit_id, $address_field,
$theList);
+ $row = $wpdb->query($query);
+
+ if(count($datum_ids) == count($addresses)) {
+ for($i = 0; $i < count($datum_ids); $i++) {
+ WpExhibitGeocoder::lookup($exhibit_id, $address_field,
$datum_ids[$i], $addresses[$i]);
+ }
+ return true;
+ } else {
+ return false;
+ }
}

// Returns true if the Exhibit contains any geocoded data, false
otherwise.

Reply all
Reply to author
Forward
0 new messages