J
John
Hi
This is just a snip of a program I don't know if it's a Perl or MySQL
problem
Basically, there is a list of tables in the array 'all'.
Prioblem = the program will create backups of all except the first table.
I can re-arrange the tables in the array 'all', but the first one still does
not get a backup created.
Any ideas?
John
for (my $j=0; $j<$total; $j++) {
my $table=$all[$j] ;
create_MySQL ($table)
}
sub create_MySQL {
my ($table)=@_;
my $backup='old_' . $table;
# backup existing table
my ($dbh,$sql,$sth);
$dbh=$library->MySQL_connection;
print "<hr>$table<hr>";
$sql="DROP TABLE IF EXISTS $backup"; $sth=$dbh->prepare($sql);
$sth->execute or die "Unable to execute query: $dbh->errstr<br>";
$sql="RENAME TABLE $table TO $backup"; $sth=$dbh->prepare($sql);
$sth->execute or die "Unable to execute query: $dbh->errstr<br>";
This is just a snip of a program I don't know if it's a Perl or MySQL
problem
Basically, there is a list of tables in the array 'all'.
Prioblem = the program will create backups of all except the first table.
I can re-arrange the tables in the array 'all', but the first one still does
not get a backup created.
Any ideas?
John
for (my $j=0; $j<$total; $j++) {
my $table=$all[$j] ;
create_MySQL ($table)
}
sub create_MySQL {
my ($table)=@_;
my $backup='old_' . $table;
# backup existing table
my ($dbh,$sql,$sth);
$dbh=$library->MySQL_connection;
print "<hr>$table<hr>";
$sql="DROP TABLE IF EXISTS $backup"; $sth=$dbh->prepare($sql);
$sth->execute or die "Unable to execute query: $dbh->errstr<br>";
$sql="RENAME TABLE $table TO $backup"; $sth=$dbh->prepare($sql);
$sth->execute or die "Unable to execute query: $dbh->errstr<br>";