RE: [PHP] Duplicating a Record in MySQL
| From: | John W. Holmes | Date: | Sat, 19 Oct 2002 19:52:08 +0000 |
| Subject: | RE: [PHP] Duplicating a Record in MySQL | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-120621@lists.php.net to get a copy of this message | ||
> >> It's not strictly php, but does anyone know an easy way to
duplicate a
> >> record in MySQL. It would be nice if you could write something
like:
> >>
> >> COPY * from table WHERE id = 6;
> >>
> >> and have it insert a new record into the table with the next id
> >>number.
>
> >I think that if you have to do this, you've got design issues. Why
not
> >just keep a "count" column in the row and increment that, instead of
> >duplicating the row.
>
> >---John Holmes...
> John,
> Here's the application: I'm creating a daily report online, eg. with
> Title,
> Report no., Date, Author, Subject Headings, Text, etc., etc.. The
report
> is
> stored in a MySQL table. When it comes time to write a new report, I
> would
> like to be able to call up an existing report, upon which to base the
new
> one, and copy the record. Then make changes where necessary and
update
> the
> record.
So have PHP select out the row you want to "copy", make your changes to
it with PHP or a form, then have PHP insert a new row into the database.
Why copy data when you're going to change it.
---John Holmes...