dbTalk Databases Forums  

creating databases

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss creating databases in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Marcel Wolf
 
Posts: n/a

Default creating databases - 01-13-2004 , 08:15 AM






Hi
I am interested in running a PHP app that when it comes up it checks to
see if the requuired database is present. If not it creates it and the
tables required within. I was trying to do this by pg_connect
(dbname=test) and if I got an error I would trying to use pg_query
(CREATE test). This was disallowed because there was no link?
What is the best way of doing this?
Thanks
Marcel


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly


Reply With Quote
  #2  
Old   
Devrim GUNDUZ
 
Posts: n/a

Default Re: creating databases - 01-13-2004 , 08:17 AM






-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hi,

On Tue, 13 Jan 2004, Marcel Wolf wrote:

Quote:
I am interested in running a PHP app that when it comes up it checks to
see if the requuired database is present. If not it creates it and the
tables required within. I was trying to do this by pg_connect
(dbname=test) and if I got an error I would trying to use pg_query
(CREATE test). This was disallowed because there was no link?
What is the best way of doing this?
Then use template1 as the initial database.

if (!@pg_connect("dbname=test")) {
$conn = pg_connect ("dbname=template1");
pg_query ($conn, "CREATE DATABASE test");
}

will work, I think.

Regards,
- --
Devrim GUNDUZ
devrim (AT) gunduz (DOT) org devrim.gunduz (AT) linux (DOT) org.tr
http://www.TDMSoft.com
http://www.gunduz.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFAA/4Wtl86P3SPfQ4RAldeAKCBwm+voxYKYGk6Ja+uyyywXyA5xwCg u86q
oyLxTiu6J5lRsDXJ+uWnsp0=
=Lhio
-----END PGP SIGNATURE-----


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.