Re: Querying the system catalog

From: Bruno LEVEQUE <bruno(dot)leveque(at)net6d(dot)com>
To: Marcel Wolf <mwolfs(at)comcast(dot)net>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Querying the system catalog
Date: 2004-01-27 22:30:53
Message-ID: Pine.LNX.4.58.0401272323560.622@moissac.leveque.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi,

I am not a guru of php, so ...

But, if it can help you, here is a little code I use :

$conn=pg_connect("host=localhost user=bruno dbname=agenda");
if (!$conn) {
echo "Couldn't connect to agenda.<BR>";
exit;
}

$query="SET DATESTYLE TO PostgreSQL,European";
# execution de la requete
pg_query($conn, $query);

$query="SELECT * from agenda ";

# execution de la requete
$result = pg_query($conn, $query);

$arr = pg_fetch_all($result);

for ($i=0; $i<$NbLigne;$i++)
{
if ($arr[$i]["heures"] == ....
....
and so

Bruno

On Tue, 27 Jan 2004, Marcel Wolf wrote:

> Hello group
> I am trying to follow through on advice I received from you earlier. I
> would like to check for my database when I logon and if it is not there
> create it( I am using php to write web apps). I am able to connect to
> the template1 and query for pg_database. But I am getting a parse error
> on the following (XXX).
>
> Error message:
> "Expected T_STRING or T_VARIABLE"
>
>
>
> Code :
> $link=pg_connect('user=marcel dbname=template1') or die ("Couldn't
> connect to template1 try again.<br>");
>
> $query = "SELECT * FROM pg_database";
>
> $result = pg_query ($query) or die ("Couldn't get the
> database names".pg_last_error());
>
> // If it worked get the database names.
>
> $database= pg_fetch_array ($result) or print ("Can't get the
> array of databases<br>");
>
> XXX print (" the 1st database is $database['datname'].<br>");
>
> die ("Finshed my test.<br>");
>
> Is this the correct way to query the system catalog for the existing
> databases? Is this questions addressed to the wrong group and maybe
> should be addressed to the php_pgsql group?
> Again thanks for the help
> Marcel Wolf
>

Bruno LEVEQUE
System Engineer
SARL NET6D
bruno(dot)leveque(at)net6d(dot)com
http://www.net6d.com

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Andre Dubuc 2004-01-27 23:23:38 Re: Querying the system catalog
Previous Message Marcel Wolf 2004-01-27 22:07:09 Querying the system catalog