Re: Comment about the bug #7120
| From: | Jani Taskinen | Date: | Fri, 13 Oct 2000 12:41:59 +0000 |
| Subject: | Re: Comment about the bug #7120 | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-34895@lists.php.net to get a copy of this message | ||
On Fri, 13 Oct 2000, Michael wrote:
>I read the manual, for both mysql_pconnect() and
>mysql_select_db() functions. And I still don't understand
>why mysql_pconnect() return two different link identifiers
>if it uses the same link, as described in the example I gave.
>Shoudn't it return the same value if it is the same link?
You don't have to care about those different 'link' ids..
It's magic. Believe me, it works.
And you do not need to use mysql_pconnect() on the same page
twice if you only want to change the database and that database
is in the same server as the other one is. Just use mysql_select_db().
Try this:
<?php
$ds = mysql_pconnect("localhost", "user", "pass");
mysql_select_db("database1",$ds);
$sr = mysql_query("SELECT * FROM existingtable");
echo "link: $ds result: $sr<br>";
$ds = mysql_pconnect("localhost", "user", "pass");
mysql_select_db("database1",$ds);
$sr = mysql_query("SELECT * FROM nonexistingtable");
echo "link: $ds result: $sr<br>";
$ds = mysql_pconnect("localhost", "user", "pass");
mysql_select_db("database2",$ds);
$sr = mysql_query("SELECT * FROM existingtable");
echo "link: $ds result: $sr<br>";
$ds = mysql_pconnect("localhost", "user", "pass");
mysql_select_db("database2",$ds);
$sr = mysql_query("SELECT * FROM nonexistingtable");
echo "link: $ds result: $sr<br>";
mysql_select_db("database1",$ds);
$sr = mysql_query("SELECT * FROM existingtable");
echo "link: $ds result: $sr<br>";
mysql_select_db("database2",$ds);
$sr = mysql_query("SELECT * FROM existingtable");
echo "link: $ds result: $sr<br>";
?>
I hope this clarifies these funcs for you?
And convinces you of the fact that there isn't any
bug in mysql_pconnect().
--Jani