IF(FIND_IN_SET('temporaire', 'statut'), 'temporary', ''))
FROM #x4dat#.adresses;
+INSERT INTO profile_addresses (pid, jobid, id, postalCode, pub, comment,
+ latitude, longitude, countryId, type)
+ SELECT uid, entrid, 0, postcode, adr_pub, NULL, glat, glng,
+ IF(country = '' OR country = '00', NULL, country), 'job'
+ FROM #x4dat#.entreprises;
+
DROP TABLE IF EXISTS geoloc_countries;
CREATE TABLE geoloc_countries (
iso_3166_1_a2 CHAR(2) NOT NULL,
// Fills the 'text' field in profile_addresses.
for ($pid = $minPid; $pid < $maxPid + 1; ++$pid) {
+ // First deals with home addresses (located in #x4dat#.adresses).
$res = XDB::iterator("SELECT a.adrid AS id, a.adr1, a.adr2, a.adr3,
UNIX_TIMESTAMP(a.datemaj) AS datemaj,
a.postcode, a.city, a.cityid, a.region, a.regiontxt,
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,
+ 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))
+ 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']);
+ }
}
function get_address_text($adr)