You are here: Re: MYSQL - PHP « PHP Programming Language « IT news, forums, messages
Re: MYSQL - PHP

Posted by Dave on 11/10/92 11:16

Dave (dave@REMOVEbundook.com) decided we needed to hear...
> Colin McKinnon (colin.deletethis@andthis.mms3.com) decided we needed to
> hear...
> > Angelos wrote:
> >
> > > First of all sorry if this is not the correct newsgroup for this question,
> > > but I am using PHP with MYSQL and someone here could have an answer and
> > > the experience.
> > >
> >
> > This is the wrong newsgroup.
> >
> > > REPLACE INTO content SELECT bak_content_id, bak_content_title FROM
> > > content_bak WHERE backup_id = '".$_GET['buckup_id']."'";
> > >
> > <snip>
> > > What I want to do is to REPLACE the TABLE CONTENT content_id = $x with
> > > the TABLE CONTENT backup_id = $y AND bak_content_id =$x
> > >
> >
> > REPLACE INTO content (id, title)
> > SELECT bak_content_id, bak_content_title
> > FROM content_bak
> > WHERE backup_id={$_GET['backup_id']}
> >
> > You might find a good book on SQL & MySQL in particular of benefit.
> >
> > C.
> $_GET['backup_id'] has to be validated first though right? I think
> thats what the OP is getting at.
> e.g. If table CONTENT has a row - (1, 'fred') and table CONTENT_BAK
> has a row - (1, 2, 'bill') and the intention is to restore the
> CONTENT row for content_id 1, then the wrong row will be
> replaced (or inserted) if $_GET['backup_id'] = 1
<snip>
Actually to do it as I described you need to already know the
content_id, so instead of my original long-winded solution, you
may as well just add...
AND bak_content_id = '$content_id'
to the end of Colin's statement and do it that way ;)
--
Dave <dave@REMOVEbundook.com>
(Remove REMOVE for email address)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация