mrjgreen / db-sync

PHP library with command line tool for efficiently syncing tables between remote MySQL databases
MIT License
292 stars 91 forks source link

Using PHP Non-CommandLine - Sync All tables #41

Closed rajendradewani closed 6 years ago

rajendradewani commented 6 years ago

Hi I am using php page and have added code from the sample.

I am able to sync single table. I would like to sync all the tables. Instead of specifying tables names in my php code would it be possible to sync all the tables.

Could you please share a sample code for the same.

rene-hermenau commented 6 years ago

@rajendradewani Did you already try to iterate over all tables and use a loop?

foreach ($tables as $sourceTable){
      $sourceTable = new Table($sourceConnection, $sourceDb, $sourceTable);

      $targetTable = new Table($targetConnection, $targetDb, 'prefix_' . $sourceTable);
      ...
     $sync->sync($sourceTable, $targetTable);
}
rajendradewani commented 6 years ago

Thank you @rene-hermenau :-) This fixed the reported issue.