in reply to Checking for DB table existence using DBI/DBD

I believe your code is equivalent to:

sub does_table_exist { my ($db_handle, $table_name) = @_; my $query_handle = $db_handle->prepare("DESC $table_name"); $query_handle->{RaiseError} = 0; $query_handle->{PrintError} = 0; return $query_handle->execute(); }

You didn't take into account PrintError. The above clears RaiseError and PrintError, but only only for the sth created to execute DESC.

By the way, you're not quoting the table name, so still have a bug. You'll probably save yourself some trouble using rnahi's solution.

Replies are listed 'Best First'.
Re^2: Checking for DB table existence using DBI/DBD
by shemp (Deacon) on Oct 13, 2005 at 21:46 UTC
    Describe doesn't need the table name quoted, at least not with the MySQL DBD.

    I use the most powerful debugger available: print!
      It does if the table name has special characters such as spaces in it, right?
        yes, you've got me there.

        I use the most powerful debugger available: print!