★ wanayoo — archive 1999 http://www.php.net/manual/function.pg-pconnect.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to PostgreSQL
Quick Reference
German version of this pageJapanese version of this pageItalian version of this pageFrench version of this pageHungarian version of this page
PostgreSQL
* pg_close
* pg_cmdtuples
* pg_connect
* pg_dbname
* pg_errormessage
* pg_exec
* pg_fetch_array
* pg_fetch_object
* pg_fetch_row
* pg_fieldisnull
* pg_fieldname
* pg_fieldnum
* pg_fieldprtlen
* pg_fieldsize
* pg_fieldtype
* pg_freeresult
* pg_getlastoid
* pg_host
* pg_loclose
* pg_locreate
* pg_loexport
* pg_loimport
* pg_loopen
* pg_loread
* pg_loreadall
* pg_lounlink
* pg_lowrite
* pg_numfields
* pg_numrows
* pg_options
* pg_pconnect
* pg_port
* pg_result
* pg_trace
* pg_tty
* pg_untrace
Manual: pg_pconnect
View the source code for this pageSearch the site



Previous page
 pg_options
 Updated
Sat, 12 Aug 2000
pg_port 
Next page


pg_pconnect

(PHP3 , PHP4 )

pg_pconnect --  Open a persistent PostgreSQL connection

Description

int pg_pconnect (string host, string port, string options, string tty, string dbname)

Returns a connection index on success, or false if the connection could not be made. Opens a persistent connection to a PostgreSQL database. Each of the arguments should be a quoted string, including the port number. The options and tty arguments are optional and can be left out. This function returns a connection index that is needed by other PostgreSQL functions. You can have multiple persistent connections open at once. See also pg_connect().

A connection can also established with the following command: $conn = pg_pconnect("dbname=marliese port=5432"); Other parameters besides dbname and port are host, tty, options, user and password.


User Contributed Notes: pg_pconnect


jakr@dial.pipex.com
17-Sep-1999 12:29
What is the 'options' string for ? Is it for specifying a userid/password ? If not, I think this is important functionality, since currently databases must provide access to user 'nobody' if that is how apache is set up (and it usually is). By being able to specify user/password, and configuring postgresql to accept these kinds of connections, security would be improved ? At the moment, it seems the only reasonable solution to using PHP/pgsql is to have PHP being or wrapped in a setuid.


epowell@yuck.net
31-Oct-1999 08:57
Reading the PostgreSQL programming documentation is helpful in figuring out what things like what goes into the 'options' string... the PHP interface appears to be heavily based on PostgreSQL's libpq programming interface.


bobesr@yahoo.com
18-Jan-2000 11:32
URGENT PLease:
What is the difference between pg_connect and pg_pconnect ?
If the script crash (or stop) befor pg_close the connection will
be still ? If yes how can I close it ? Do I need to close it ?



guenther.mair@web.by.com
28-Jan-2000 09:32
i figured out that persistant connections are far faster as general connections if you are doing multiple selects on your tables. this should happen for other sql queries too, of course. however up to now i'm not able to close persistant connections with pg_close. is this a bug? is there something not mentioned here, that i am missing? help would be heavily appreciated!


guenther.mair@web.by.com
31-Jan-2000 10:10
for further information have a look at http://www.php.net/manual/features.persistent-connections.php3


php@elysium.ltd.uk
22-Feb-2000 11:01
The easiest way to connect to a PostgreSQL DB as another user is to do something like the following:

<pre>
$db_options = "host=<hostname|ip address> user=<username> password=password";
</pre>

Then to do a persistent connection do:
<pre>
pg_pConnect($db_options);
</pre>
or for a non persistent connection do:
pg_Connect($db_options);



clecerf@univ-paris8.fr
23-Mar-2000 10:00
The "Options" parameter. It seems to worry some users...
Refering to the libpq doc of Postgres, it is used to set trace/debug options to be sent to backend.
Probably no use for a PHP3 programmer.



tumor@iris.kkt.bme.hu
30-Mar-2000 05:39
Well, pg_pconnect is ALMOST identical to pg_Connect. The difference is that when you make something nasty with the PSQL server (like reseting it) then pg_pConnect still tryes to use the previous connection. This creates some nice broken_pipe errors (and maybe some more). I do not know that resetting the http server would help it, I think it would. As pg_connect creates a new connection every time (that is why it is \"so slow\") this error does not occurs with it. Really this is not a bug, but perphaps you could do something with it, and it may help some people working with recently changing pg security settings... Good bug hunting...


dmitri@graphictype.com
10-May-2000 04:12
<pre>
How to reset persistent connections:

killall -USR1 httpd
</pre>



 About Notes


Previous page
 pg_options
 Updated
Sat, 12 Aug 2000
pg_port 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.