Address: changed country to country_id with Country table
This commit is contained in:
Executable
+60
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
//require 'vendor/autoload.php';
|
||||
require("../config/config.php");
|
||||
|
||||
define('FRONKDB_SQLDEBUG',false);
|
||||
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
|
||||
|
||||
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
|
||||
|
||||
$me = new User(1);
|
||||
define("INTERNAL_USER_ID", $me->id);
|
||||
define("INTERNAL_USER_USERNAME", $me->username);
|
||||
$layout = Layout::singleton();
|
||||
|
||||
|
||||
$austria = CountryModel::getFirst(["name" => "Österreich"]);
|
||||
|
||||
if(!$austria) {
|
||||
die("Österreich nicht gefunden\n");
|
||||
}
|
||||
|
||||
foreach(AddressModel::getAll() as $address) {
|
||||
if($address->country_id) continue;
|
||||
$country = false;
|
||||
|
||||
$c = strtolower(trim($address->country));
|
||||
|
||||
if(!$c || $c == "österreich" || $c == "Österreich" || $c == "Österreic" || $c == "Österreicch" || $c == "Österrreich" || $c == "at" || $c == "a") {
|
||||
$country = $austria;
|
||||
}
|
||||
|
||||
if($c == "oesterreic" || $c == "oesterreicch" || $c == "oesterrreich") {
|
||||
$country = $austria;
|
||||
}
|
||||
|
||||
if(!$country) {
|
||||
$cc = __($address->country, "cc");
|
||||
if(!$cc) {
|
||||
echo "cc for ".$address->country." not found";
|
||||
continue;
|
||||
}
|
||||
$country = CountryModel::getFirst(["isocode" => $cc]);
|
||||
if(!$country) {
|
||||
echo "Country for isocode $cc ($c) not found\n";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$address->country_id = $country->id;
|
||||
if(!$address->save()) {
|
||||
die(__FILE__.": Error saving address!\n");
|
||||
}
|
||||
|
||||
//echo $address->country." => ".$country->name." ".$country->isocode."\n";
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user