# Closing mysql_pconnects.

- Thread: https://externals.io/message/40148
- Original archive: https://news-web.php.net/php.internals/40148
- Started by Richard Quadling on 2008-08-29T22:09:41+00:00
- Messages: 7
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #40148 — Richard Quadling — 2008-08-29T22:09:41+00:00

URL: https://externals.io/message/40148#40148

Hi.

Can someone point me to where or how PHP DOESN'T close persistent
connections (those opened using mysql_pconnect()) when mysql_close()
is called with that connection.

Sorry to ask such an obvious question, but I'm not seeing it.

Thank you.

-- 
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

---

## #40149 — Lupus Michaelis — 2008-08-30T02:40:55+00:00

URL: https://externals.io/message/40148#40149 · In reply to: #40148

Richard Quadling a écrit :
>  Can someone point me to where or how PHP DOESN'T close persistent
> connections

   Maybe because it is... persistent ?

> (those opened using mysql_pconnect()) when mysql_close()
> is called with that connection.

   See <http://php.net/mysql_pconnect>

-- 
Mickaël Wolff aka Lupus Michaelis
http://lupusmic.org

---

## #40150 — Robert Cummings — 2008-08-30T02:58:37+00:00

URL: https://externals.io/message/40148#40150 · In reply to: #40149

> Richard Quadling a écrit :
> > […]
> 
>    Maybe because it is... persistent ?

He's probably trying to learn how to do the same. This is internals
after all and not php-general.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP

---

## #40151 — Lupus Michaelis — 2008-08-30T03:53:25+00:00

URL: https://externals.io/message/40148#40151 · In reply to: #40150

Robert Cummings a écrit :

> He's probably trying to learn how to do the same. This is internals
> after all and not php-general.

   Sorry for the private mail, I did't see you sent here too.

   It is in the documentation that mysql_close don't close a mysql_pconnect.

-- 
Mickaël Wolff aka Lupus Michaelis
http://lupusmic.org

---

## #40152 — Ronald Chmara — 2008-08-30T05:46:22+00:00

URL: https://externals.io/message/40148#40152 · In reply to: #40150

> 
> > […]
>
> He's probably trying to learn how to do the same. This is internals
> after all and not php-general.

If you'd like to peruse the source, to implement a similar feature,  
one place to look is the web gui to CVS for the function:

http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/php_mysql.c? 
revision=1.213.2.6.2.16.2.26&view=markup

-Bop

---

## #40189 — Richard Quadling — 2008-08-31T16:37:34+00:00

URL: https://externals.io/message/40148#40189 · In reply to: #40152

2008/8/30 Ronald Chmara <ron@opus1.com>:
>
> 
>
> > […]
>
> If you'd like to peruse the source, to implement a similar feature, one
> place to look is the web gui to CVS for the function:
>
> http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/php_mysql.c?revision=1.213.2.6.2.16.2.26&view=markup
>
> -Bop
> --
> 
> 
>
>



What I'm trying to determine is how persistent connections are ignored
when mysql_close() is called against a connection which was opened via
mysql_pconnect().

I've looked at the source and can see that mysql_connect and
mysql_pconnect call
php_mysql_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, x); where x is
1 or 0 (persistent or not).

But in mysql_close(), there is no reference to the persistent setting
of MySG(allow_persistent) or any other persistent related variable.

So, I'm missing something. And that's why I asked.

Regards,

Richard Quadling.




-- 
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

---

## #40190 — Robert Cummings — 2008-08-31T17:04:28+00:00

URL: https://externals.io/message/40148#40190 · In reply to: #40189

>
> What I'm trying to determine is how persistent connections are ignored
> when mysql_close() is called against a connection which was opened via
> mysql_pconnect().
> 
> I've looked at the source and can see that mysql_connect and
> mysql_pconnect call
> php_mysql_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, x); where x is
> 1 or 0 (persistent or not).
> 
> But in mysql_close(), there is no reference to the persistent setting
> of MySG(allow_persistent) or any other persistent related variable.
> 
> So, I'm missing something. And that's why I asked.

>From my browsing of the code, specifically related to following the
"persistent" var, it appears that php_mysql_do_connect() doesn't add it
to the resource list of normal connections when the connection is
created. As such it wouldn't get closed if you attempted to close it.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP
