Fixes wrong id retrieval in geocoding.
authorStéphane Jacob <sj@m4x.org>
Tue, 13 Jul 2010 20:49:11 +0000 (22:49 +0200)
committerStéphane Jacob <sj@m4x.org>
Tue, 13 Jul 2010 20:49:11 +0000 (22:49 +0200)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
include/geocoding.inc.php

index 845a314..a828366 100644 (file)
@@ -47,9 +47,10 @@ abstract class Geocoder {
                                 WHERE  name = {?}",
                               $address[$area . 'Name']);
             if ($res->numRows() == 0) {
-                $address[$area . 'Id'] = XDB::execute("INSERT INTO  " . $databases[$area] . " (name, country)
-                                                            VALUES  ({?}, {?})",
-                                                      $address[$area . 'Name'], $address['countryId']);
+                XDB::execute('INSERT INTO  ' . $databases[$area] . ' (name, country)
+                                   VALUES  ({?}, {?})',
+                             $address[$area . 'Name'], $address['countryId']);
+                $address[$area . 'Id'] = XDB::insertId();
             } else {
                 $address[$area . 'Id'] = $res->fetchOneCell();
             }