Only uses autoload to require validation classes.
[platal.git] / upgrade / newdirectory-0.0.1 / addresses.php
index 209521f..01193d8 100755 (executable)
@@ -38,30 +38,31 @@ for ($pid = $minPid; $pid < $maxPid + 1; ++$pid) {
 
     while ($address = $res->next()) {
         $text = get_address_text($address);
-        XDB::iterator('UPDATE  profile_addresses
-                          SET  text = {?}
-                        WHERE  pid = {?} AND type = {?} AND id = {?}',
-                      $text, $pid, $address['pro'] ? 'job' : 'home', $address['id']);
+        XDB::execute('UPDATE  profile_addresses
+                         SET  text = {?}
+                       WHERE  pid = {?} AND type = {?} AND id = {?}',
+                     $text, $pid, $address['pro'] ? 'job' : 'home', $address['id']);
     }
 
     // Then deals with job addresses (located in #x4dat#.entreprises).
-    $res  = XDB::iterator("SELECT  e.entrid AS jobid, 0 AS id, e.adr1, e.adr2, e.adr3,
+    $res  = XDB::iterator("SELECT  e.entrid AS id,  j.id AS jobid, e.adr1, e.adr2, e.adr3,
                                    e.postcode, e.city, e.cityid, e.region, e.regiontxt,
                                    e.adr_pub AS pub, e.country, gp.pays AS countrytxt, gp.display,
                                    e.glat AS precise_lat, e.glng AS precise_lon
                              FROM  #x4dat#.entreprises AS e
                        INNER JOIN  #x4dat#.geoloc_pays AS gp ON (gp.a2 = e.country)
                        INNER JOIN  account_profiles    AS ap ON (e.uid = ap.uid AND FIND_IN_SET('owner', ap.perms))
+                       INNER JOIN  profile_job_enum    AS j  ON (e.entreprise = j.name)
                             WHERE  ap.pid = {?}
                          ORDER BY  e.entrid",
                            $pid);
 
     while ($address = $res->next()) {
         $text = get_address_text($address);
-        XDB::iterator('UPDATE  profile_addresses
-                          SET  text = {?}
-                        WHERE  pid = {?} AND type = {?} AND id = {?} AND jobid = {?}',
-                      $text, $pid, 'job', $address['id'], $address['jobid']);
+        XDB::execute('UPDATE  profile_addresses
+                         SET  text = {?}
+                       WHERE  pid = {?} AND type = {?} AND id = {?} AND jobid = {?}',
+                     $text, $pid, 'job', $address['id'], $address['jobid']);
     }
 }