At 01:39, 19991008, toxalot@stripped wrote:
>Anyway, what I wanted to do was have a default product table and copy and
>rename it for each new site.
Jennifer, there are a couple of ways to do this. If you're using 3.23,
you can do something like this:
CREATE $new_table SELECT * FROM default_products
That's easy, huh?
If you're using 3.22, you have to be more round-about. You can store
the default table definition in your program, like this:
# Instead of hard-coding this in your program, you could query the
# database with "SHOW FIELDS FROM default_products", and use the
# results to make a new CREATE TABLE statement down below.
my $default_table = <<'EOS';
CREATE TABLE :NAME: (
id INT UNSIGNED NOT NULL etc...,
Then do something like this to make a new table:
(my $create = $default_table) =~ s/:NAME:/$new_table/;
$dbh->do("INSERT INTO $new_table SELECT * FROM default_products");
|• Copying tables||toxalot||8 Oct|
| • Re: Copying tables||Thimble Smith||8 Oct|