PHP Classes

MySQL Restore: Execute batches of MySQL queries read from files

Recommend this page to a friend!
     
  Info   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 59%Total: 2,072 All time: 1,894 This week: 488Up
Version License Categories
mysql-restore 1.0GNU General Publi...Databases
Description 

Author

This class can be used to execute batches of MySQL database queries read from files or text strings. It can be useful to restore backups of MySQL database that generate SQL query lists meant for that purpose.

The SQL data can be compressed with gzip algorithm. The class can also build an array of queries strings in a class variable without executing the queries.

Picture of Vagharshak Tozalakyan
Name: Vagharshak Tozalakyan <contact>
Classes: 22 packages by
Country: United States United States
Age: 44
All time rank: 61 in United States United States
Week rank: 200 Down22 in United States United States Down
Innovation award
Innovation award
Nominee: 7x

Details

MySQL database restore class, version 1.0.0 HOW TO USE 1. Create the instance of MySQL_Restore class. 2. Define necessary properties. 3. Call Execute() method to create backup. require_once 'mysql_restore.class.php'; $restore_obj = new MySQL_Restore(); $restore_obj->server = 'localhost'; $restore_obj->username = 'username'; $restore_obj->password = 'password'; $restore_obj->database = 'dbname'; if (!$restore_obj->Execute(MSR_FILE, 'backups/10_02_05__12_24_22.sql.gz', true, false)) { die($restore_obj->error); } PUBLIC PROPERTIES var $server = 'localhost'; The name of MySQL server. var $port = 3306; The port of MySQl server. var $username = 'root'; Database username. var $password = ''; Database password. var $database = ''; Name of the database. var $link_id = -1; MySQL link identifier of the current connection. You can set this if you want to connect the MySQL server by your own. var $connected = false; Set true if the connection is already established before calling Execute(). var $queries = array(); Array of separate queries from SQL file or SQL commands string. var $error = ''; Error message. PUBLIC METHODS function Execute($param, $mode = MSR_STRING, $is_compressed = false, $split_only = false) $param - filename or SQL commands string; $mode - Type of SQL data: MSR_STRING - param is the string of SQL commands; MSR_FILE - param is the filename of SQL file. $is_compressed - decompress GZip compressed SQL data (file or string)? $split_only - only split SQL content to separate queries without executing them.

  Files folder image Files (2)  
File Role Description
Plain text file mysql_restore.class.php Class Source
Accessible without login Plain text file readme.txt Doc. Readme

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:2,072
This week:0
All time:1,894
This week:488Up
 User Ratings  
 
 All time
Utility:92%StarStarStarStarStar
Consistency:60%StarStarStarStar
Documentation:67%StarStarStarStar
Examples:-
Tests:-
Videos:-
Overall:59%StarStarStar
Rank:1315