1. Go to this page and download the library: Download idct/database-comparator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
idct / database-comparator example snippets
$comparator = new Compare();
$objects = new PdoSource();
$pdo = new PDO(...); //your database connection details here
$objects->setPdo($pdo)
->setQueryAll('select * from some_table limit :limit offset :offset') //limit and offset will be dynamically updated
->setQuerySingle('select * from some_table where {_keys}')
->setSingleKeys(['id']);
$comparator->addSource('main', $objects)
->addSource('test', $objects); /* in this case we shall use the same
source as for left calls it will use queryAll and for right ones
querySingle */
$output = (new SimpleOutput())
->setBaseFilename('somepath/comparison_{source}.log');
// {source} token will be dynamically replaced
$comparator->setOutput($output)
->run();
//report differences
var_dump($comparator->getDiffsCount());