Skip to content

Syncronize two databases (or more) with PHP + MySQL/PDO

Notifications You must be signed in to change notification settings

IvanPrat/PHPDBSync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

PHPDBSync

This class will handle the syncronization between two or more databases when you run it. It will handle not just the tables, but also the cols and its values at once in order to make each other equal.

Options

Just include the file, set the options and sync two databases or more.

  • fromDBHost: the host for the main database with correct structure
  • fromDB: your main database
  • fromDBUser: main database username
  • fromDBPassword: main database password
  • toDBHost: host for the targeted database(s) to get sync
  • toDBUser: targeted database username
  • toDBPassword: targeted database password
  • databases: array with all the databases that must get sync

Using the Class

<?php

/*
* Sometimes it takes a long time, we recommend to Set Time Limit to 0
*/  
$sync = new PHPDBSync;

/*
* The main Database that possesses the good structure
*/
$sync->fromDBHost = 'localhost';
$sync->fromDB = 'mymain_db';
$sync->fromDBUser = 'root';
$sync->fromDBPassword = 'root';

/*
* Targeted Databases to get sync
*/
$sync->toDBHost = 'localhost';
$sync->toDBUser = 'root';
$sync->toDBPassword = 'root';

/*
* All the databases listed that you want to sync
*/
$sync->databases = array(
  'db_to_get_sync'
);

/*
* Run the Class
*/
$sync->syncDatabases();

/*
* Show Debug Results
*/
$sync->debugResults();

?>

License

Copyright (c) 2017 Iván Prat (https://github.com/IvanPrat)

Licensed under the MIT License (http://www.opensource.org/licenses/mit-license.php)

About

Syncronize two databases (or more) with PHP + MySQL/PDO

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages