Testing if a mysql table exists

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sam

    Testing if a mysql table exists

    Is there a simple way to test if a mysql table exists?
    JUST One line !


  • Andy Hassall

    #2
    Re: Testing if a mysql table exists

    On Fri, 17 Oct 2003 01:02:57 +0200, "sam" <rbaba99@carama il.com> wrote:
    [color=blue]
    >Is there a simple way to test if a mysql table exists?
    >JUST One line ![/color]

    Depends how many commands you put on one line.

    $res = mysql_query("sh ow table status like '$tablename'")
    or die(mysql_error ());
    $table_exists = mysql_num_rows( $res) == 1;

    --
    Andy Hassall (andy@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
    Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

    Comment

    Working...