List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:July 3 1999 2:47pm
Subject:Re: wanted: mysql_select_db with a NULL (or empty) db
View as plain text  
At 4:47 PM -0700 7/2/1999, terry jones wrote:
>I'd like to be able to select "no" database via a call to
>mysql_select_db.
>
>Here's my reasoning. I'm writing an API that allows people to do
>things with MySQL databases. When they first connect, they have not
>selected a database. This is the state I'd like to be able to return
>to.
>
>My application allows the caller to switch to another db (via
>mysql_select_db), but it is possible that the db selected is not a db
>created by my library. I don't want to leave the connection with a
>selected db that is not one my application created.
>
>Instead, when they ask me to select a new db, I'd like to call
>mysql_select_db and look at the tables in that database and if they
>are not the ones I expect to see, unselect that db. I don't want to do
>something like selecting (or making) a "test" db, because apart from
>being a kludge it may not exist and/or I may not have permission to do
>that. It would be cleanest if I could just call mysql_select_db(mysql,
>NULL) and have my connection return to the way it was when I first
>called mysql_connect. Presumably this would be quite easily to
>implement.


Couldn't you just call mysql_close() and then open a new
connection with a NULL database name argument for mysql_real_connect()?

--
Paul DuBois, paul@stripped
Northern League Chronicles: http://www.snake.net/nl/
Thread
wanted: mysql_select_db with a NULL (or empty) dbterry jones3 Jul
  • Re: wanted: mysql_select_db with a NULL (or empty) dbPaul DuBois3 Jul