|
| Nial Muecke wrote:
> Hi,
>
> I am hoping that someone can help me?
>
> What i want to do is connect to a database host where I can no be sure that
> there is a database and then create a new database.
>
> What would be good, would be if i could create a new MBD2 connection and
> pass an option to it that says "if db not exist then create db" which would
> then go and create the db and return the connection.
>
> Any help would be most appreciated, even if it to say that it cant be done.
>
If you're creating per-user DBs you should still have a "main" DB for
the site. Connect to that one first and then try to create the new one
and switch over to that. You'll probably need to work out some
DB-specific query in order to check if the DB exists. Then just apply a
"CREATE DATABASE ..." query.
And your user will of course require the CREATE PRIVILEGE.
Note that, depending upon your needs, you may want to set the "new_link"
option to TRUE when connecting to the second DB:
http://pear.php.net/manual/en/packa...2.intro-dsn.php
brian
|
|