mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-06-01 06:27:15 +00:00
add new method createDump()
This commit is contained in:
parent
56683a6104
commit
d105fa5155
|
@ -2269,5 +2269,39 @@ class SeedDMS_Core_DMS {
|
|||
$this->callbacks[$name] = array($func, $params);
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Create an sql dump of the complete database
|
||||
*
|
||||
* @param string $filename name of dump file
|
||||
*/
|
||||
function createDump($filename) { /* {{{ */
|
||||
$h = fopen($filename, "w");
|
||||
if(!$h)
|
||||
return false;
|
||||
|
||||
$tables = $this->db->TableList('TABLES');
|
||||
foreach($tables as $table) {
|
||||
$query = "SELECT * FROM `".$table."`";
|
||||
$records = $this->db->getResultArray($query);
|
||||
fwrite($h,"\n-- TABLE: ".$table."--\n\n");
|
||||
foreach($records as $record) {
|
||||
$values="";
|
||||
$i = 1;
|
||||
foreach ($record as $column) {
|
||||
if (is_numeric($column)) $values .= $column;
|
||||
else $values .= $this->db->qstr($column);
|
||||
|
||||
if ($i<(count($record))) $values .= ",";
|
||||
$i++;
|
||||
}
|
||||
|
||||
fwrite($h, "INSERT INTO `".$table."` VALUES (".$values.");\n");
|
||||
}
|
||||
}
|
||||
|
||||
fclose($h);
|
||||
return true;
|
||||
} /* }}} */
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue
Block a user