Re: moving content from one database to another, help
| From: | JJ Harrison | Date: | Sun, 25 Aug 2002 02:16:17 +0000 |
| Subject: | Re: moving content from one database to another, help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-114019@lists.php.net to get a copy of this message | ||
> I'm sorry, I thought that what I was asking was very simple. but everyone
wants to make it more
> difficult then it actually is.
>
> Just looking for some help on writing a small bit of code that will allow
me to grab the missing
> records from stage and move them to production. If I have 5 records on
stage and 2 on production
> then I need to move the last 3 cause the first 2 are already there.
Nothing has changed, there is
> no way without someone commiting an illegal act can the production
database be touched. NOTHING.
> I can guarantee you 100% that id1 on stage is the same as id1 on
production.
Why have two tables if the stucture is the same? You should think about a
enum/set coloumn so that you can change it or have both
Anyway. You will have to do a select query to get the data. Then an insert
query and put that same data into a different table e.g
something like:
$query = "select * from TABLE NAME HERE WHERE ...";
$result = mysql_query($query) or die("Query failed: $query<br>" .
mysql_error());
$query = "insert (coloumn_1, coloumn_2, etc...) into TABLE NAME HERE
(field_1, field_2, etc...) WHERE ...";
$result = mysql_query($query) or die("Query failed: $query<br>" .
mysql_error());
You could loop that and just check if the coloumn exists.
That IMHO is a very bad DB design though. research enum and/or set fields
for mySQL.
--
JJ Harrison
webmaster@tececo.com
www.tececo.com
--
Please reply on the list/newsgroup unless the reply it OT.
> I have no problem except for the fact that I have been writting code for 4
weeks straight on 7
> different projects and I am tired and was looking for something that I was
missing and so far I
> have had several conversation about datbase theories.
>
> Once more I will try and explain what I am trying to do.
>
> Two databases one production and one stage. They are the same table/field
wise. As in Production
> is a copy of stage. stage is where they stage their content and get it
ready for promotion to
> production. There is only ONE difference, only ONE.. that difference is
since stage is where they
> stage their new content, stage will have the newest content, and therefore
more rows in certain
> tables. This is where my example of stage has 5 row and production has 2
rows. First I want to
> turn the status of the first two from online to achived and then I want to
add the new content
> into the production table. so after this promotion table 1 on production
will have 5 and stage
> will have 5.
>
>
>
>
>
>
> --- Richard Lynch <rich@phpbootcamp.com> wrote:
> > First, use a better subject line. Many experts have just deleted your
email
> > un-read.
> >
> > >I am trying to promote content from one database to another, but I
can't do
> > >just a simple dump ..
> > >oh no that would be to easy. these are seperate databases, the tables
are
> > >the same and the records
> > >are the same, well stage database will always have more records.
> >
> > Knowing that "stage database" will always have more records is useful...
> >
> > But can records be *changed* in "stage database" and then have to be put
> > into the other one?
> >
> > Can records in the *other* database change?
> >
> > If it's possible that *both* copies of the same record changed, which
one do
> > I pick? Are they time-stamped? Is "staged" always "better" (or
"worse")?
> > Should I just flip a coin? Should I replace any NULL values with
non-NULLs
> > and quit? How about I just choose the value of every other field from
each
> > database and use that? I'm getting ridiculous, but you've really not
> > clearly defined what your application should do, and, really, there's no
way
> > in the world we could "guess" and get it right.
> >
> > >database 1 - table 1 to compare database 2 - table 1
> > >
> > >database 1 table 1 = 2 rows
> > >database 2 table 1 = 5 rows
> > >
> > >need to move those 3 extra rows to database 1 and then change the
status of
> > >the 2 old rows in
> > >database 1.
> >
> > What status where how? What do you mean by status?
> >
> > If your real problem is that you have to answer "I don't know" to all
the
> > above, then there's nothing we can do to help you, really... You'll
need to
> > do some powerful thinking, or force your boss/client into doing it,
which is
> > even harder, and that's not really something to be done by a mailing
list.
> >
> > --
> > Like Music? http://l-i-e.com/artists.htm
> >
>
>
> =====
> --------------------------------------------------------
> "Theres no such thing as a problem unless the servers are on fire!"
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Finance - Get real-time stock quotes
> http://finance.yahoo.com