$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';
- $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, 'importSQL')){
- echo "Importing SQL from module $m using Module::importSQL\n";
- $x->importSQL();
+ if(method_exists($x, 'importModuleSQL')){
+ echo "Importing SQL from module $m using Module::importModuleSQL\n";
+ $x->opts = $this->opts;
+ $x->rootDir = $this->rootDir;
+ $x->importModuleSQL($dburl);
continue;
}
};
function importpgsqldir($url, $dir, $disable_triggers = false)
{
+ $ff = HTML_FlexyFramework::get();
+
require_once 'System.php';
$cat = System::which('cat');
$psql = System::which('psql');
echo $psql_cmd . "\n" ;
echo "scan : $dir\n";
+ if (is_file($dir)) {
+ $files = array($dir);
+
+ } else {
- $files = glob($dir.'/*.sql');
- uksort($files, 'strcasecmp');
+
+ $files = glob($dir.'/*.sql');
+ uksort($files, 'strcasecmp');
+ }
//$lsort = create_function('$a,$b','return strlen($a) > strlen($b) ? 1 : -1;');
//usort($files, $lsort);
$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);