PHP Classes

DBSync: Synchronize the schema of MySQL databases

Recommend this page to a friend!
  Info   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum (4)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 65%Total: 3,153 This week: 1All time: 1,140 This week: 560Up
Version License Categories
dbsync 1.0.0GNU General Publi...Databases
Description 

Author

This class provides a way to synchronize the schema of one or more databases from the schema of a master database.

Currently, the class only synchronizes the database schema, not data in the database tables.

For now it supports MySQL databases but the schema manipulation functions are implemented in a separate driver class. Therefore, support for other types of databases can be implemented by writing new driver classes.

Innovation Award
PHP Programming Innovation award winner
June 2005
Winner


Prize: One book of choice by O'Reilly
Sometimes it is necessary to alter the schema of a database to introduce new features or change the current features of an application.

Usually the new or changed application features are tested first in a development environment.

When the new developments are ready to go in production, it is necessary to update the schema of the database in production to have the same structure of the database in the development environment.

This class provides a solution for this problem by comparing the schemas of the database in the development and production environments and performing the necessary alterations to synchronize the schemas.

Manuel Lemos
Picture of Diogo Resende
Name: Diogo Resende <contact>
Classes: 10 packages by
Country: Portugal Portugal
Age: 41
All time rank: 292 in Portugal Portugal
Week rank: 411 Down3 in Portugal Portugal Down
Innovation award
Innovation award
Nominee: 4x

Winner: 2x

Details

.------------------------------------------------------------------------------. | This is a quick reference, details on class methods are inside the file. | '------------------------------------------------------------------------------' The public methods available under DBSync class are: # SetHomeDatabase() Parameters: $database $type (default = 'mysql') $host (default = 'localhost') $user (default = 'root') $pass (default = '') Set the Home Database settings. These are the settings of the database that has it's structure correct and all other should guide thru. # AddSyncDatabase() Parameters: $database $type (default = 'mysql') $host (default = 'localhost') $user (default = 'root') $pass (default = '') Add a Sync Database. This function is used to add databases that will be synched with the Home Database. # Sync() Synchronise all the Sync Databases with the Home Database. A simple script to synchronise a database db1 with db2 on your localhost mysql server could be as simple as this: <?php include 'class.dbsync.php'; $dbsync = new DBSync(); $dbsync->SetHomeDatabase('db1'); $dbsync->AddSyncDatabase('db2'); $dbsync->Sync(); ?> This is as simple as this because of default parameters. They assume your local database server is at the localhost on a mysql server width user root and with no password. If you want you can create diferente database drivers for MSSQL and others by creating the class and naming it like class.<type>.dbsync.php. This way, when you try to sync a database and chose <type> as the type of the database, the DBSync class will try and load the correct file and make the sync. Be aware you cannot change the names of the methods, they must be exactly the same as in class.mysql.dbsync.php and should do obviously the same thing. If you have any doubt, mail me at: me@diogoresende.net

  Files folder image Files  
File Role Description
Plain text file class.dbsync.mysql.php Class MySQL Sync Driver
Plain text file class.dbsync.php Class Main Class
Accessible without login Plain text file README Doc. Read this!
Accessible without login Image file reload.png Icon Image on test.php
Accessible without login Plain text file test.php Example Test script

 Version Control Unique User Downloads Download Rankings  
 0%
Total:3,153
This week:1
All time:1,140
This week:560Up
User Ratings User Comments (3)
 All time
Utility:81%StarStarStarStarStar
Consistency:84%StarStarStarStarStar
Documentation:79%StarStarStarStar
Examples:81%StarStarStarStarStar
Tests:-
Videos:-
Overall:65%StarStarStarStar
Rank:627