/**
* Table Definition for builder_tables
*/
-require_once 'DB/DataObject.php';
+class_exists('DB_DataObject') ? '' : require_once 'DB/DataObject.php';
class Pman_Builder_DataObjects_Builder_tables extends DB_DataObject
{
$this->syncDatabase();
HTML_FlexyFramework::get()->page->jok("DONE");
}
+
+ if(!empty($q['_dumpDatabase'])){
+ $this->dumpDatabase();
+ }
+
+// if(!empty($q['_dumpTable'])){
+// $this->dumpTable($q['_dumpTable']);
+// }
}
}
- print_r(Services_JSON::stringify($this->tableSchema($k),null,4));exit;
+
$set = array(
'name' => $k,
'descrip' => isset($desc[$k]) ? $desc[$k] : '',
return $cache[$tn];
}
+// function dumpTable($tn)
+// {
+// $roo = HTML_FlexyFramework::get()->page;
+//
+// if(empty($tn)){
+// return;
+// }
+//
+// $do = DB_DataObject::factory($tn);
+// if (!is_a($do,'DB_DataObject')) {
+// return;
+// }
+//
+// $dsn = HTML_FlexyFramework::get()->database;
+//
+// $database = explode('@', $dsn);
+//
+// $ui = str_replace('mysql://', '', $database[0]);
+//
+// $user = array_shift(explode(':', $ui));
+// $pw = array_pop(explode(':', $ui));
+//
+// $host = array_shift(explode('/', $database[1]));
+// $dn = array_pop(explode('/', $database[1]));
+//
+// $cmd = "mysqldump -u{$user} ";
+// if(!empty($pw)){
+// $cmd .= "-p{$pw} ";
+// }
+//
+// $cmd .= "--no-create-info summit {$tn}";
+//
+// require_once 'System.php';
+//
+// $tmpdir = System::mktemp("-d dump");
+//
+// $path = $tmpdir . '/' . $tn . '.sql';
+//
+// ob_start();
+//
+// passthru($cmd);
+//
+// $data = ob_get_contents();
+//
+// ob_end_clean();
+//
+// file_put_contents($path, $data);
+//
+// header('Content-Description: File Transfer');
+// header ('Content-Type: application/octet-stream');
+// header("Content-Disposition: attachment; filename=\"".basename($path)."\";" );
+// header("Expires: 0");
+// header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
+// header("Pragma: public");
+// header('Content-Length: ' . filesize($path));
+//
+// @ob_clean();
+// flush();
+// readfile($path);
+//
+// exit;
+// }
+
+ function dumpDatabase()
+ {
+ $ff = HTML_FlexyFramework::get();
+
+ $dsn = HTML_FlexyFramework::get()->database;
+
+ $database = explode('@', $dsn);
+
+ $ui = str_replace('mysql://', '', $database[0]);
+
+ $user = array_shift(explode(':', $ui));
+ $pw = array_pop(explode(':', $ui));
+
+ $host = array_shift(explode('/', $database[1]));
+ $dn = array_pop(explode('/', $database[1]));
+
+ $cmd = "mysqldump -h {$host} -u{$user} ";
+ if(!empty($pw)){
+ $cmd .= "-p{$pw} ";
+ }
+
+ $cmd .= "--extended-insert=FALSE --no-create-info {$dn}";
+
+ require_once 'System.php';
+
+ $tmpdir = System::mktemp("-d dump");
+
+ $path = $tmpdir . '/' . $dn . '.sql';
+
+ ob_start();
+
+ passthru($cmd);
+
+ $data = ob_get_contents();
+
+ ob_end_clean();
+
+ file_put_contents($path, $data);
+
+ header('Content-Description: File Transfer');
+ header ('Content-Type: application/octet-stream');
+ header("Content-Disposition: attachment; filename=\"".basename($path)."\";" );
+ header("Expires: 0");
+ header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
+ header("Pragma: public");
+ header('Content-Length: ' . filesize($path));
+
+ @ob_clean();
+ flush();
+ readfile($path);
+
+ exit;
+ }
+
}