UpdateDatabase.php
authorAlan Knowles <alan@roojs.com>
Fri, 15 Nov 2013 05:58:53 +0000 (13:58 +0800)
committerAlan Knowles <alan@roojs.com>
Fri, 15 Nov 2013 05:58:53 +0000 (13:58 +0800)
UpdateDatabase.php

index 498904f..b78e04c 100644 (file)
@@ -79,17 +79,29 @@ class Pman_Xtuple_UpdateDatabase extends Pman
     
     // called to ensure options are correct.
     // before any data is imported / started..
-    function checkOpts()
+    function checkOpts($opts)
     {
-        $core_opts = HTML_FlexyFramework::get()->page->opts;
-        if (!empty($core_opts['init']) && empty($core_opts['base'])) {
+        $opts = HTML_FlexyFramework::get()->page->opts;
+        if (!empty($opts['init']) && empty($opts['base'])) {
             die("--base=XXX  must be set when using --init ");
         }
         
         
         
     }
-    
+    function loadFromFile($db, $file)
+    {
+        if (!file_exists($file)) {
+            die("can not found account json file :$file \n");
+        }
+
+        $accounts = json_decode(file_get_contents($opt['source']),true);
+        
+        DB_DataObject::factory('accnt')->importFromArray($this, $accounts);
+        
+        die("DONE! \n");
+    }
+    }
     
     function get($k = '',$opt)
     {
@@ -103,7 +115,7 @@ class Pman_Xtuple_UpdateDatabase extends Pman
                 continue;
             }
             $type = str_replace('_', '-', substr($o,6));
-            $this->loadFromFile,$
+            $this->loadFromFile($type, $v);
         }