Re: Postgres + PHP question: username in pg_connect?

From: Andrew Sullivan <sullivana(at)bpl(dot)on(dot)ca>
To: user Postgresql ML <pgsql-general(at)postgresql(dot)org>
Subject: Re: Postgres + PHP question: username in pg_connect?
Date: 2000-07-19 13:13:55
Message-ID: 20000719091355.C3502@bpl.on.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)bpl(dot)on(dot)ca> Burlington Public Library
+1 905 639 3611 x158 2331 New Street
Burlington, Ontario, Canada L7R 1J4

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2000-07-19 14:26:24 Re: [HACKERS] Re: PRIMARY KEY & INHERITANCE (fwd)
Previous Message Pavel Janík ml. 2000-07-19 11:18:41 Re: [HACKERS] Re: pg_dump with BLOBS & V7.0.2 UPDATED