PHP Classes

Retrieving, executing and saving partial data from SQL dump: Extract table dumps from full MySQL database dumps

Recommend this page to a friend!
  Info   Screenshots Screenshots   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 357 All time: 6,936 This week: 455Up
Version License PHP version Categories
data-from-dump 1.0BSD License5.0PHP 5, Databases, Systems administration
Description 

Author

This class can be used to extract table dumps from full MySQL database dumps.

It can parse a MySQL full database and extract the SQL CREATE and INSERT statements just for given tables.

The extracted SQL statements may be executed immediately or saved to a new database dump file.

Sometimes database administrators or programmers need to restore or copy only a few data tables from one server to another, but all they have is a full DUMP file created by standard utilities like 'dump' (for MySQL).
For production systems it can be really HUGE file, so the task seems to be not so simple.

CDataFromDump class aimed to resolve the problem: it parses source dump file and grabs only data for desired table list. These CREATE TABLES and INSERT operators can be instantly executed on connected database or saved into a new SQL file, for editing and/or executing later.

Currently the class has following features:
- During the first scan, it tries to creates "metadata" file for processed dump, so next retrieving jobs will be much faster.
- Grabs only SQL operators for the tables from passed list
CREATE TABLE operators can be executed/included into result SQL file or NOT, according to passed parameters.

Innovation Award
PHP Programming Innovation award nominee
September 2010
Number 7


Prize: One downloadable e-book of choice by O'Reilly
mysqldump is a tool for taking backups of MySQL databases. It is part of the distribution of MySQL. It works by generating SQL statements that can be used to recreate the database later.

There are several PHP components that do practically the same as the mysqldump command. However, to restore a backup taken with mysqldump usually you execute all the contained SQL statements, and so you have to recreate the whole database.

This class makes the process of restoring MySQL database backups more convenient. It allows recreating only list of database tables of your choice, instead of recreating all.

It even allows saving the relevant SQL statements into a separate file instead of executing them right away. This way you can recreate only the needed tables in multiple steps, eventually in different machines.

Manuel Lemos
Picture of Alexander Selifonov
  Performance   Level  
Name: Alexander Selifonov is available for providing paid consulting. Contact Alexander Selifonov .
Classes: 20 packages by
Country: Russian Federation Russian Federation
Age: 61
All time rank: 502 in Russian Federation Russian Federation
Week rank: 360 Down19 in Russian Federation Russian Federation Down
Innovation award
Innovation award
Nominee: 16x

Winner: 2x

Screenshots  
  • dfd-screenshot.png
  Files folder image Files  
File Role Description
Plain text file datafromdump.php Class Main class source
Accessible without login Plain text file grabsql.php Example Using example
Accessible without login HTML file datafromdump.en.htm Doc. Documentation (English)
Accessible without login HTML file datafromdump.ru.htm Doc. Documentation (Russian)

 Version Control Unique User Downloads Download Rankings  
 0%
Total:357
This week:0
All time:6,936
This week:455Up