new method createDump() which was in SeedDMS_Core_DMS

This commit is contained in:
Uwe Steinmann 2021-09-17 19:00:57 +02:00
parent 2789e017eb
commit 90aac2f1ad

View File

@ -913,4 +913,33 @@ class SeedDMS_Core_DatabaseAccess {
} }
return $field; return $field;
} /* }}} */ } /* }}} */
/**
* Create an sql dump of the complete database
*
* @param resource $fp name of dump file
* @return bool
*/
function createDump($fp) { /* {{{ */
$tables = $this->TableList('TABLES');
foreach($tables as $table) {
$query = "SELECT * FROM `".$table."`";
$records = $this->getResultArray($query);
fwrite($fp,"\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->qstr($column);
if ($i<(count($record))) $values .= ",";
$i++;
}
fwrite($fp, "INSERT INTO `".$table."` VALUES (".$values.");\n");
}
}
return true;
} /* }}} */
} }