}
- function loadFromFile($db, $file)
+ function importFromArray($db, $file)
{
continue;
}
$type = str_replace('_', '-', substr($o,6));
- $this->loadFromFile($type, $v);
+ $this->importFromArray($type, $v);
}
+
- if($k == 'accnt'){
- if(empty($opt['source'])){
- die("Missing Source directory for account json files! Try -f [JSON file path] \n");
- }
-
- if (!file_exists($opt['source'])) {
- die("can not found account json file : {$opt['source']} \n");
- }
-
- $accounts = json_decode(file_get_contents($opt['source']),true);
-
- DB_DataObject::factory('accnt')->importFromArray($this, $accounts);
-
- die("DONE! \n");
- }
-
- if($k == 'curr_symbol'){
- if(!empty($opt['base'])){
- DB_DataObject::factory('curr_symbol')->setBase($this, $opt['base']);
- die("DONE! \n");
- }
-
- if(!empty($opt['source'])){
-
- if (!file_exists($opt['source'])) {
- die("can not found currency json file : {$opt['source']} \n");
- }
-
- $currencies = json_decode(file_get_contents($opt['source']),true);
-
- DB_DataObject::factory('curr_symbol')->importFromArray($this, $currencies);
- die("DONE! \n");
- }
-
- die("Missing Base Currency or Source directory for Currency json files! Try -b [base currency] or -f [JSON file path]\n");
- }
-
- if($k == 'location'){
- if(empty($opt['source'])){
- die("Missing Source directory for location json file! Try -f [JSON file path] \n");
- }
-
- if (!file_exists($opt['source'])) {
- die("can not found location json file : {$opt['source']} \n");
- }
-
- $locations = json_decode(file_get_contents($opt['source']),true);
-
- DB_DataObject::factory('location')->importFromArray($this, $locations);
-
- die("DONE! \n");
- }
-
- if($k == 'terms'){
- if(empty($opt['source'])){
- die("Missing Source directory for terms json file! Try -f [JSON file path] \n");
- }
-
- if (!file_exists($opt['source'])) {
- die("can not found terms json file : {$opt['source']} \n");
- }
-
- $terms = json_decode(file_get_contents($opt['source']),true);
-
- DB_DataObject::factory('terms')->importFromArray($this, $terms);
-
- die("DONE! \n");
- }
-
+
$this->updateData($k);