Bug #54181 [Opn->Bgs]: MySQLi doesn't always reuse persistent link inside same script
| From: | scottmac@php.net | Date: | Mon, 07 Mar 2011 16:28:32 +0000 |
| Subject: | Bug #54181 [Opn->Bgs]: MySQLi doesn't always reuse persistent link inside same script | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-159280@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=54181&edit=1
ID: 54181
Updated by: scottmac@php.net
Reported by: carsten_sttgt at gmx dot de
Summary: MySQLi doesn't always reuse persistent link inside
same script
-Status: Open
+Status: Bogus
Type: Bug
Package: MySQLi related
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
This doesn't have anything to do with persistent connections, with
mysql_connect()
if you open a connection with the same parameters it won't return a new
link
unless you set the 4th parameter to true.
This is working as expected, persistent connections are only re-used if
they're no
longer in use by another script.
Previous Comments:
------------------------------------------------------------------------
[2011-03-07 15:10:49] carsten_sttgt at gmx dot de
Description:
------------
If I open an existing persistent link a second (or 3rd, ...) time inside
the same script, MySQLi is only reusing the existent link if I have
explicitly closed the link before. At the moment it's always creating a
new link.
With MySQL it's working as expected.
Test script:
---------------
<?php
$con1 = mysqli_connect('p:localhost', 'foo', '');
var_dump($con1->thread_id);
$con2 = mysqli_connect('p:localhost', 'foo', '');
var_dump($con2->thread_id);
mysqli_close($con1);
mysqli_close($con2);
echo "---\n";
$con3 = mysqli_connect('p:localhost', 'bar', '');
var_dump($con3->thread_id);
mysqli_close($con3);
$con4 = mysqli_connect('p:localhost', 'bar', '');
var_dump($con4->thread_id);
mysqli_close($con4);
echo "===\n";
$con5 = mysql_pconnect('localhost', 'foo', '');
var_dump(mysql_thread_id($con5));
$con6 = mysql_pconnect('localhost', 'foo', '');
var_dump(mysql_thread_id($con6));
mysql_close($con5);
mysql_close($con6);
echo "---\n";
$con7 = mysql_pconnect('localhost', 'bar', '');
var_dump(mysql_thread_id($con7));
mysql_close($con7);
$con8 = mysql_pconnect('localhost', 'bar', '');
var_dump(mysql_thread_id($con8));
mysql_close($con8);
?>
Expected result:
----------------
int(1)
int(1)
---
int(2)
int(2)
===
int(3)
int(3)
---
int(4)
int(4)
Actual result:
--------------
int(1)
int(2)
---
int(3)
int(3)
===
int(4)
int(4)
---
int(5)
int(5)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=54181&edit=1