DataObjects/Core_person_signup.php
[Pman.Core] / UpdateDatabase.php
index 7ff7959..a81d927 100644 (file)
@@ -173,12 +173,12 @@ class Pman_Core_UpdateDatabase extends Pman
         
         $ff = HTML_Flexyframework::get();
         
-        $url = parse_url($ff->DB_DataObject['database']);
+        $dburl = parse_url($ff->DB_DataObject['database']);
         
         //$this->{'import' . $url['scheme']}($url);
         
-        $dbtype = $url['scheme'];
-        $dirmethod = 'import' . $url['scheme'] . '.dir';
+        $dbtype = $dburl['scheme'];
+        $dirmethod = 'import' . $dburl['scheme'] . 'dir';
         
         
        
@@ -197,16 +197,17 @@ class Pman_Core_UpdateDatabase extends Pman
             
             
             
-            $file = $this->rootDir. "/Pman/$module/UpdateDatabase.php";
-            if($module != 'Core' && file_exists($file)){
+            $file = $this->rootDir. "/Pman/$m/UpdateDatabase.php";
+            if($m != 'Core' && file_exists($file)){
                 
                 require_once $file;
-                $class = "Pman_{$module}_UpdateDatabase";
+                $class = "Pman_{$m}_UpdateDatabase";
                 $x = new $class;
                 if(method_exists($x, 'importModuleSQL')){
                     echo "Importing SQL from module $m using Module::importModuleSQL\n";
-                    $x->opts = $this->opts();
-                    $x->importModuleSQL();
+                    $x->opts = $this->opts;
+                    $x->rootDir = $this->rootDir;
+                    $x->importModuleSQL($dburl);
                     continue;
                 }
             };
@@ -257,6 +258,8 @@ class Pman_Core_UpdateDatabase extends Pman
     
     function importpgsqldir($url, $dir, $disable_triggers = false)
     {
+        $ff = HTML_FlexyFramework::get();
+        
         require_once 'System.php';
         $cat = System::which('cat');
         $psql = System::which('psql');
@@ -275,13 +278,19 @@ class Pman_Core_UpdateDatabase extends Pman
         echo $psql_cmd . "\n" ;
         echo "scan : $dir\n";
         
-        $files = glob($dir.'/*.sql');
-        uksort($files, 'strcasecmp');
+        if (is_file($dir)) {
+            $files = array($dir);
+
+        } else {
+        
+        
+            $files = glob($dir.'/*.sql');
+            uksort($files, 'strcasecmp');
+        }
         //$lsort = create_function('$a,$b','return strlen($a) > strlen($b) ? 1 : -1;');
         //usort($files, $lsort);
         
         
-        
         foreach($files as $bfn) {
 
 
@@ -306,8 +315,7 @@ class Pman_Core_UpdateDatabase extends Pman
 
             $cmd = "$psql_cmd  < " . escapeshellarg($fn ? $fn : $bfn) . ' 2>&1' ;
 
-            echo "$bfn:   $cmd ". ($this->cli ? "\n" : "<BR>\n");
-
+            echo "$bfn:   $cmd ". ($ff->cli ? "\n" : "<BR>\n");
 
             passthru($cmd);
 
@@ -707,6 +715,32 @@ class Pman_Core_UpdateDatabase extends Pman
         
     }
     
+    function fixMysqlInnodb()
+    {
+        // innodb in single files is far more efficient that MYD or one big innodb file.
+        // first check if database is using this format.
+        $db = DB_DataObject::factory('core_enum');
+        $db->query("show variables like 'innodb_file_per_table'");
+        $db->fetch();
+        var_dump($db);
+        // Value should == ON
+        
+        // I think it needs to look in the mysql directory.... to see if the idb exists..
+        $db = DB_DataObject::factory('core_enum');
+        $db->query("SHOW TABLE STATUS");
+        // Engine should be InnoDB - and file XXX.idb should exist...
+        
+        
+
+        
+        
+        
+        
+        
+    }
+    
+    
     /** ------------- schema fixing ... there is an issue with data imported having the wrong sequence names... --- */
     
     function fixSequencesMysql()