in reply to Re: MySQL Database Check...
in thread MySQL Database Check...

Maybe this works in mySQL, but as a general rule it does not work in DBI because SHOW TABLES is not SQL. I use Oracle and in Oracle, SHOW TABLES is a SQL*Plus command but does not work via DBI prepare/execute calls. I believe this is why the DBI table methods were added -- to insulate these database specifics and allow table queries to exist across all databases in a consistent manner.

Replies are listed 'Best First'.
Re: Re: Re: MySQL Database Check...
by tachyon (Chancellor) on Jan 02, 2003 at 05:41 UTC

    I did specify it was MySQL specific (and yes it does work ;-) but as you state using the DBI table methods or even just wrapping in an eval or changing RaiseError will be more portable options.

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      Well, thanks guys. After I posted, I was playing around with it, and I remembered a few things...

      Here is how I got it to work.

      $sth = $dbh1->selectrow_array ( "SELECT * FROM `some_table_name` LIMIT 1"); if ($dbh1->errstr) { #Does not exist } else { # DOES exist }

      I used LIMIT 1 in case it does exist and has thousands of entries. This way it will be faster, if it does exist. Otherwise it don't matter.

      It worked for what I was wanting it to do.

      thx,
      Richard
Re: Re: Re: MySQL Database Check...
by vek (Prior) on Jan 02, 2003 at 13:20 UTC
    While you are 100% correct steves, the OP did specifically state that this would be for MySQL. In which case tachyon was not wrong in mentioning 'SHOW TABLES' IMHO.

    -- vek --