Skip site navigation (1) Skip section navigation (2)

Re: creating databases

From: Devrim GUNDUZ <devrim(at)gunduz(dot)org>
To: Marcel Wolf <mwolfs(at)comcast(dot)net>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: creating databases
Date: 2004-01-13 14:17:56
Message-ID: Pine.LNX.4.44.0401131613170.11515-100000@emo.org.tr (view raw or flat)
Thread:
Lists: pgsql-novice
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hi,

On Tue, 13 Jan 2004, Marcel Wolf wrote:

> 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 (!(at)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(dot)gunduz(at)linux(dot)org(dot)tr 
			http://www.TDMSoft.com
			http://www.gunduz.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

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


In response to

pgsql-novice by date

Next:From: Devrim GUNDUZDate: 2004-01-13 14:42:02
Subject: Re: PostgreSQL booting automaticaly
Previous:From: Marcel WolfDate: 2004-01-13 14:15:25
Subject: creating databases

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group