<?php require "connect.inc.php"; require "../addon/Exporter.php"; $appname = 'MySQL Backup Class'; $myurl = 'http://localhost'; $backupPath = 'C:\\apachefriends\\xampp\\htdocs\\anyDB2'; // export table content as sql statements #$sqlData = Exporter::getDBDataDump($db); $tables = $db->getTables(); $struct = Exporter::dbStructure($db, $tables); print_r($struct); #foreach($sqlData as $key => $data) { # echo "--$key--<br>"; # echo nl2br($data); #} #$file = Exporter::dumpDataFileBuilder($sqlData); #echo $file; #Exporter::dataOnly($db, $appname, $myurl, $backupPath); #echo $sfile; //require "disconnect.inc.php"; //////////////////////////////////////////////////////////////////////// echo '<hr>'; highlight_file(__FILE__);
/** * Method to do full backup of data and structure * @param */ function dataAndStruct(&$db, $appname, $myurl, $backupPath) { //get the table names $tableNames = $db->getTables(); //get the structure of the db $struct = Exporter::dbStructure($db, $tableNames); //build the headers bit $writefile = Exporter::sqlfileHeaders($appname, $myurl); //set the data variable to null $dataArray = null; //get the data $dataArray = Exporter::getDBDataDump($db, ANYDB_DUMP_SQL); //how many tables are there? $tblCount = count($tableNames); //pass the count and the arrays to the filebuilder function $dataFile = Exporter::writeData($dataArray); //build the writefile for the create table statements foreach ($struct as $output) { $writefile .= Exporter::writeStructure($output); } //put in a sql comment to start the table data $writefile .= "-- Table data... \n\n"; //write table data to sql file $writefile .= $dataFile; $filename = Exporter::writeSQL($backupPath, $writefile); return $filename; }