KDragon Posted June 16, 2006 Share Posted June 16, 2006 I know of the functionality of some of php's built-in functions that allow you to write to a file and if the file doesn't exist it will create it. I would like to do this same thing with a database. Most people just say to use phpMyAdmin to create the databases first but this seems a little convoluted and it seems to me I should be able to just write or find a php function that can create a database if and only if it isn't already created. I could use phpMyAdmin but does anyone know of way of doing what I want to do? Quote Link to comment https://forums.phpfreaks.com/topic/12129-mysql-database-question/ Share on other sites More sharing options...
joquius Posted June 16, 2006 Share Posted June 16, 2006 What do you need this for? I mean in any case it's much better not to have a function checking if the database exists every moment. Quote Link to comment https://forums.phpfreaks.com/topic/12129-mysql-database-question/#findComment-46185 Share on other sites More sharing options...
KDragon Posted June 16, 2006 Author Share Posted June 16, 2006 [!--quoteo(post=384479:date=Jun 16 2006, 03:36 AM:name=joquius)--][div class=\'quotetop\']QUOTE(joquius @ Jun 16 2006, 03:36 AM) [snapback]384479[/snapback][/div][div class=\'quotemain\'][!--quotec--]What do you need this for? I mean in any case it's much better not to have a function checking if the database exists every moment.[/quote]I don't really need it. I just wondered if it could be done. I don't need it to check every moment. Just every time I have to write something to a particular database. Quote Link to comment https://forums.phpfreaks.com/topic/12129-mysql-database-question/#findComment-46195 Share on other sites More sharing options...
joquius Posted June 16, 2006 Share Posted June 16, 2006 The more predefined stuff you have the better. Reduces the time for processing code, if you are going to need the database, it's better to create it anyway Quote Link to comment https://forums.phpfreaks.com/topic/12129-mysql-database-question/#findComment-46198 Share on other sites More sharing options...
d_barszczak Posted June 16, 2006 Share Posted June 16, 2006 [!--quoteo(post=384489:date=Jun 16 2006, 09:08 AM:name=KDragon)--][div class=\'quotetop\']QUOTE(KDragon @ Jun 16 2006, 09:08 AM) [snapback]384489[/snapback][/div][div class=\'quotemain\'][!--quotec--]I don't really need it. I just wondered if it could be done. I don't need it to check every moment. Just every time I have to write something to a particular database.[/quote]You can use a query like this i think!!CREATE DATABASE MyNewDatabase [IF NOT EXISTS]; Quote Link to comment https://forums.phpfreaks.com/topic/12129-mysql-database-question/#findComment-46204 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.