Make a php-function to sync one master-db to clients-dbs

In Progress Posted Mar 11, 2016 Paid on delivery
In Progress Paid on delivery

Urgent project.

I want a sync-function/script written in PHP against MySQL. Meaning I want to sync data-structure in one database to a number of other databases. Please read and understand the requirements closely. I'm in a hurry and very busy, so I can't afford to write it myself. It is not a difficult project, but you just need to awake and know php by heart.

Assume I have a list like below. First line is the source-db, the next ones is the target-dbs.

masterdb1:hostname:username:password

db1:hostname:username:password|usertable:1-3;menutable:1-4

db2:hostname:username:password|usertable:1-9;menutable:1-4

db3:hostname:username:password|fieldtable;menutable,grouptable;pagetable:1

There are about 7 tables to care about in each.

All tables have a key-column like user_id, menu_id, field_id (ending with ID). And table is named "user", "menu","field".

So verry easy to use (and understand I hope!).

foreach db in list:

- Compare definition for 7 tables: field_names, field_length, field-type (integer, varchar 255 or text) and default value against masterdb1 only.

- If the table-columns in db1, db2, db3 and so on has a different order, field_name, lengt or type: you must adjust them.

- In addition: The | in list above, lets say db1, is saying that you should also query table "user" for field user_id where values are between 1 and 3.

- The values returned from each of the queries above shall update and/or create all the user_id values between 1 and 3 for instance in that db.

- If no table exist, it shall be created and look 100% like masterdb1, but only with the first few rows (like 1 to 3).

Quick and dirty (simplified):

Forach db:

compare field-definition and alter/drop/modify each of db1, db2, db3 etc.

extract a few rows (select * from sometable in masterdb1 into sametable in db1)

Code-style:

I want function-oriented (not object-oriented) and easy-to-read code.

No framework or helper-class.

A-dry run shall be possible (show all the changes and sql-that will be peformed).

I need it by monday.

Table-names: user,menu,lang,string,field,group,page

Key-fields: user_id, menu_id, lang_id, string_id, field_id, group_id, page_id

MySQL PHP

Project ID: #9910837

About the project

16 proposals Remote project Active Mar 11, 2016