Re: Postgres + PHP question: username in pg_connect?

Поиск
Список
Период
Сортировка
От Andrew Sullivan
Тема Re: Postgres + PHP question: username in pg_connect?
Дата
Msg-id 20000719091355.C3502@bpl.on.ca
обсуждение исходный текст
Ответ на Postgres + PHP question: username in pg_connect?  (Erich <hh@cyberpass.net>)
Список 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 по дате отправления:

Предыдущее
От: Pavel.Janik@linux.cz (Pavel Janík ml.)
Дата:
Сообщение: Re: [HACKERS] Re: pg_dump with BLOBS & V7.0.2 UPDATED
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: [HACKERS] Re: PRIMARY KEY & INHERITANCE (fwd)