Re: Postgres + PHP question: username in pg_connect? - Mailing list pgsql-general

From Andrew Sullivan
Subject Re: Postgres + PHP question: username in pg_connect?
Date
Msg-id 20000719091355.C3502@bpl.on.ca
Whole thread Raw
In response to Postgres + PHP question: username in pg_connect?  (Erich <hh@cyberpass.net>)
List pgsql-general
On Tue, Jul 18, 2000 at 04:51:09PM -0700, Erich wrote:
>
> I'm getting ready to switch over from MySQL to Postgres for my PHP
> application.  Looking over the docs of PHP, it shows a pg_connect
> command, which doesn't accept a user name.  Any ideas on how to get it
> to connect with a specified user name?  Or do I have to run apache as
> a specific user, and have that user have a postgres user account?
> Right now, apache is running as nobody, which is pretty normal for
> apache.

The docs are incomplete.  If you read the "annotated" version of the PHP
docs, you'll see that several people complain about this.  The way to connect
with a username is

$db = pg_Connect ("host=[somehost] port=[correct port]
    dbname=[your_database] user=[username] password=[password]");

(normally you'd do that as one line).  The options aren't all necessary, so
you don't need to use passwords if you don't want.

By the way, you'd be better off, in almost every circumsntance, to use
pg_pConnect.  Then, you don't have to open a new database connection every
time you want to do an operation.  The overhead of that really hurts.

--
Andrew Sullivan                                      Computer Services
<sullivana@bpl.on.ca>                        Burlington Public Library
+1 905 639 3611 x158                                   2331 New Street
                                   Burlington, Ontario, Canada L7R 1J4

pgsql-general by date:

Previous
From: Pavel.Janik@linux.cz (Pavel Janík ml.)
Date:
Subject: Re: [HACKERS] Re: pg_dump with BLOBS & V7.0.2 UPDATED
Next
From: Stephan Szabo
Date:
Subject: Re: [HACKERS] Re: PRIMARY KEY & INHERITANCE (fwd)