4

when using pg_pconnect connections to connect from php to postgres, does pg_close :

  1. really close the connection (ruining the persistent effect) ?
  2. hand over the connection to the pconnect pool ?
Jerome WAGNER
  • 21,986
  • 8
  • 62
  • 77
  • This should be documented, have you checked the docs or are you just asking? – hakre Nov 21 '11 at 11:57
  • 1
    I checked the docs on http://php.net/manual/en/function.pg-close.php which does not clearly make its point (except for a comment that i wanted to double check on stack overflow). But you are right I missed http://php.net/manual/en/function.pg-pconnect.php : "the pg_close() will not close persistent links generated by pg_pconnect()." I'll close the question – Jerome WAGNER Nov 21 '11 at 12:06
  • Don't close, add that as an answer instead. I was just asking for feedback, so if you found the answer, add it below. You can accept it later on as well. – hakre Nov 21 '11 at 12:12

1 Answers1

5

It has to do with the PHP.ini configuration, if the label pgsql.allow_persistent is set to true then pg_close will not close the connection because it is persistent, otherwise if you set it to false pg_close will close the connection.

The documentation states on pg-pconnect:

pg_close() will not close persistent links generated by pg_pconnect()
Jerome WAGNER
  • 21,986
  • 8
  • 62
  • 77
aleroot
  • 71,077
  • 30
  • 176
  • 213