PHP Classes
elePHPant
Icontem

MySQL Restore: Execute batches of MySQL queries read from files

Recommend this page to a friend!
  Info   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2005-12-20 (10 years ago) RSS 2.0 feedStarStarStarStar 63%Total: 2,060 All time: 1,849 This week: 1,016Up
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: 23 packages by
Country: Armenia Armenia
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  
File Role Description
Plain text file mysql_restore.class.php Class Source
Accessible without login Plain text file readme.txt Doc. Readme

 Version Control Unique User Downloads Download Rankings  
 0%
Total:2,060
This week:0
All time:1,849
This week:1,016Up
 User Ratings  
 
 All time
Utility:100%StarStarStarStarStarStar
Consistency:62%StarStarStarStar
Documentation:70%StarStarStarStar
Examples:-
Tests:-
Videos:-
Overall:63%StarStarStarStar
Rank:834