Login   Register  
PHP Classes
elePHPant
Icontem

File: README

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Diogo Resende  >  DBSync  >  README  >  Download  
File: README
Role: Documentation
Content type: text/plain
Description: Read this!
Class: DBSync
Synchronize the schema of MySQL databases
Author: By
Last change:
Date: 9 years ago
Size: 2,031 bytes
 

Contents

Class file image Download
.------------------------------------------------------------------------------.
|   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