how to know a database has a specific table
Hello
I can connect with a database using user name, password, host and port.
My question is how I can know that the the database has a specific table in it (so I can know that I connect with a right database).
Database is postgres
Could you please help
Thanks
shuhu
[310 byte] By [
suhua] at [2007-11-27 6:17:59]

Open the database, then use SHOW TABLES method to get the table you need. You may do this in a loop through all the databases, saving the results in an array or other temporary way. If, then, the array contains what you are looking for, then open it. Else ignore it.
Jamwaa at 2007-7-12 17:31:33 >

If there's a situation where you don't know what database you're connecting to, you have a serious flaw in your design.And eventually the code will fail anyway when trying to access non-existing elements.So double checking for the correct database is pretty much unneeded.