This is a guest post from Daniele

After a lot of work, I released the new version (2.0) of the MySQLDump class, already introduced by this article.
MySQLDump is a class that allows to do a complete MySQL database backup with php pages.

After the inandrea’s good work there wasn’t too much space for improvements, but I think that these addition can be usefull: now it’s possible to export structures and/or data not only for the selected database but also for a single table.

The following example will explain how to export the structure and the data for the table mytable in the db mydb (the interface to the class is slightly changed from the previous version).

//Include the library
@include_once('lib_dump.php');
//Db connection
$connection = @mysql_connect('127.0.0.1','username','password');
//Create the MySQLDump class instance
//1° parameter: db name
//2° parameter: the exported file that will contain the dump
//3° parameter: create zipped file (true = zipped, false = normal)
//4° parameter: data encode (true = hexadecimal, false = plain text)
$dumper = new MySQLDump('mydb','dumpfile.sql',false,false);
//Structure export of the table 'mytable'
$dumper->getTableStructure('mytable');
//Data export of the table 'mytable'
$dumper->getTableData('mytable');

Continue Reading »