So I have two DB's, one used for draft one used for live stuff.
// Connect to the draft database
$connDraft = mysqli_connect('###.###.##.##','user','pass') OR die("There was a problem connecting to the draft database.");
// Select database
mysqli_select_db($connDraft, "draftDB") OR die("There was a problem selecting the draft database.");
// Connect to the live database
$connLive = mysqli_connect('###.###.##.##','user','pass') OR die("There was a problem connecting to the live database.");
// Select database
mysqli_select_db($connLive, "liveDB") OR die("There was a problem selecting the live database.");
The table structure will be the same, as will the table names and everything. I simply need to:
if entry_id exists in live, update otherwise insert a new record.
A - Copying from table to table i'd use
INSERT INTO table2
SELECT * FROM table1;
B - Insert vs update i'd use
INSERT ... ON DUPLICATE KEY UPDATE
C - And moving from 1 DB to another, i'd use ???
INSERT INTO liveDB.TableA
SELECT * FROM draftDB.TableB
My confusion is how to use A & B in tandem. I'm having difficulty finding a sample online. Also, is C is a proper way to accomplish this.
A sample table structure would be...
entry_id, title, status, date_created, data_edited