X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=bin%2FformatAddresses.php;h=52636efe3f8244892164b8b674589ef201ef86f3;hb=07e02fe3af9db38b14225e5bf0ed937147acb37d;hp=6b8a8dd4f9b69f43653fa2b80b5feab5d590e130;hpb=49f0caac6cf944a238401a74bce2c37c7c99583b;p=platal.git diff --git a/bin/formatAddresses.php b/bin/formatAddresses.php index 6b8a8dd..52636ef 100755 --- a/bin/formatAddresses.php +++ b/bin/formatAddresses.php @@ -1,7 +1,7 @@ #!/usr/bin/php5 -q debug = 0; // Do not store backtraces $targets = array( - 'g' => 'formatted_address', - 'p' => 'postalText' + 'g' => 'pa.formatted_address', + 'p' => 'pa.postalText' ); $ranges = array( 'f' => ' != \'\'', 'e' => ' = \'\'', - 'a' => 'IS NOT NULL' + 'a' => ' IS NOT NULL' ); $options = getopt('g::t:r:h::', array('geocode::', 'target:', 'range:', 'help::')); @@ -85,11 +86,12 @@ EOF; exit; } -print "Formats addresses addresses.\n"; +print "Formats addresses.\n"; -$where = ''; if ($range != 'a') { - $where = 'WHERE ' . $targets[$target] . $ranges[$range]; + $where = $targets[$target] . $ranges[$range]; +} else { + $where = null; } if ($geocoding_required) { @@ -102,10 +104,7 @@ if ($geocoding_required) { $display_limit = 100; } -$it = XDB::rawIterator('SELECT * - FROM profile_addresses - ' . $where . ' - ORDER BY pid, jobid, type, id'); +$it = Address::iterate(array(), array(), array(), Visibility::get(Visibility::VIEW_PRIVATE), $where); $total = $it->total(); $i = 0; @@ -113,12 +112,11 @@ $j = 0; $skipped = 0; printf("\r%u / %u", $i, $total); -while ($item = $it->next()) { - $address = new Address($item); +while ($address = $it->next()) { $address->changed = ($geocoding_required ? 1 : 0); $address->format(); if ($address->delete()) { - $address->save(); + $address->save(false); } else { ++$skipped; } @@ -139,5 +137,5 @@ if ($skipped != 0) { print "\nDone.\n"; -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8: ?>