Re: Re: mysql_query - CREATE DATABASE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I´m creating a software that use a database, and i want to include a
install.php file to install the database
of the software.

I can create the database in the install.php file with

mysql_query("CREATE DATABASE my_db",$con)
But when is created, i don´t know the complete name of the database, because
a prefix is added.




On Mon, Feb 9, 2009 at 12:17 PM, Shawn McKenzie <nospam@xxxxxxxxxxxxx>wrote:

>  R B wrote:
> > Hello,
> >
> > When i create a mysql database with the next command:
> >
> > mysql_query("CREATE DATABASE my_db",$con)
> >
> > In the server is created the database, but usually the name is created
> with
> > a prefix.
> >
> > In this case: someuser_my_db
> >
> > How can i detect with PHP the complete name of the new database created?
> >
> > Thanks
> >
>
> There may be a better way, but off the top of my head, translate this to
> PHP:
>
> use information_schema;
> select SCHEMA_NAME from SCHEMATA where SCHEMA_NAME like '%_my_db';
>
> Now of course you could have multiples there, like user_my_db and
> user2_my_db.  Not sure about that, maybe it would be the last one in the
> returned records?
>
> --
> Thanks!
> -Shawn
> http://www.spidean.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux