<?php
 
/**
 
 * This example file shows the basic uses of the DB Sync class.
 
 */
 
 
//use and include the Sync class
 
use Fogg\Db\Sync\Sync;
 
require 'Sync.php';
 
 
//Create two PDO Database connections. In theory, the database type is irrelevant.
 
$db = new PDO("mysql:host=localhost;dbname=TestDb", 'root', '****');
 
$db2 = new PDO("mysql:host=localhost;dbname=NewDb", 'root', '*******');
 
 
//Instantiate the Sync class
 
$sync = new Sync($db, $db2);
 
 
//Copy all rows from the test table. This will truncate the receiving table prior to insert
 
$sync->syncTable('test');
 
 
//Copy all rows from the test tabe. This will delete rows based on the field id prior to insert
 
$sync->syncTable('test', '*', '', false, 'id');
 
 
//Copy all rows from the test table with an id > 3, truncating the table prior to insert
 
$sync->syncTable('test', '*', 'id > 3');
 
 
//Copy the name and value fields for all rows from the test table
 
$sync->syncTable('test', 'name, value');
 
 |