Re: [PHP] copy tables

From: Cpt John W. Holmes (holmes072000_at_charter.net)
Date: 10/15/03


To: "Gronquist, Jim M" <jgronqui@indiana.edu>, <php-general@lists.php.net>
Date: Wed, 15 Oct 2003 15:51:21 -0400

From: "Gronquist, Jim M" <jgronqui@indiana.edu>

> I've set up dev and prod webservers. Users can go into the dev webserver
> content and edit it. The content is in a mysql database. I have a button
> on the webpage that says push content live. When the button is pushed I
> want it to run a php script that will copy the dev mysql table data into
> the prod mysql table.

Are these physically separete web servers? Is there any reason you couldn't
just use a "status" column in one database to mark whether something is
"dev" or "live" ?

If not, how about using a status column in the "dev" server that keeps track
of what's been pushed? Then you could use a INSERT INTO ... SELECT ...
statement to copy everything that's "unpushed" to the "live" server, and
then update the status column.

INSERT INTO liveserver.tablename SELECT * FROM devserver.tablename WHERE
pushed_column = 'unpushed';
UPDATE devserver.tablename SET pushed_column = 'pushed' WHERE pushed_column
= 'unpushed';

Wrap those in a transaction or LOCKs so you don't end up missing anything
and it should work as long as both tables are the same. Even if they are
different, you can format your INSERT ... SELECT query accordingly.

Or, if you delete things from the "dev" table after they've been "pushed",
then just use a DELETE query instead of an UPDATE query for the second one.

---John Holmes...



Relevant Pages

  • strange ADO / myODBC speed problem
    ... Server, ... The largest query took about 1 second, which was reasonable, since all ... After installing Windows 2003 Server, mySQL 5.0.24a and our website on ...
    (microsoft.public.data.ado)
  • strange myODBC / ADO speed problem....
    ... Server, ... The largest query took about 1 second, which was reasonable, since all ... After installing Windows 2003 Server, mySQL 5.0.24a and our website on ...
    (microsoft.public.vb.database.ado)
  • Re: strange ADO / myODBC speed problem
    ... After installing several components on the server ... The strange thing is that when I performed the exact same query ... I have no experience with mySQL, so I don't know if this is relevant. ... "parameter sniffing" can sometimes cause the optimizer to choose a query ...
    (microsoft.public.data.ado)
  • Re: php 5 and mysql failure
    ... MySQL result resource in ... ... If I echo the query, copy and paste in phpmyadmin, or if I perform the ... I had a big set of ids (positive response from more than one server). ...
    (comp.lang.php)
  • Re: Moving a MySQL database
    ... providing you're using the same or a newer mysql server on your new system, you just need to copy the whole data directory of your mysql installation. ... > I have a MySQL database residing on a RH9 server. ...
    (Debian-User)