ID:               32866
 User updated by:  kevin at hatry dot com
 Reported By:      kevin at hatry dot com
 Status:           Bogus
 Bug Type:         MySQL related
 Operating System: windows XP + linux
 PHP Version:      4.3.11
 New Comment:

thank you for your direct answer however this "solution" cannot work
with a heavily loaded website as it would open too much connections on
the mysql server :
for example a page called 50 times a second and opening 3 connections
at a the same time means 150 connections /sec to the mysql server
instead of 50 ! 
This situation is clearly one where the shared connection is useful.

i will try one last example to make sure you really know how i "want it
to work", please read it through and answer the last question below,
thank you.

the following script (without any function to make it clearer) :

<?php
$link1 = mysql_connect('localhost','root','',false);
$link2 = mysql_connect('localhost','root','',false);

echo "link1 : "; var_dump($link1);
echo "link2 : "; var_dump($link2);
echo 'mysql thread : '.mysql_thread_id($link2)."\n";

mysql_close($link1);

echo "-- after closing link1 :\n";
echo "link1 : "; var_dump($link1);
echo "link2 : "; var_dump($link2);
echo 'mysql thread : '.mysql_thread_id($link2)."\n";

// this query works fine and that's ok with me
mysql_query('select * from user',$link2);

$link1 = NULL;

echo "-- after link1 = NULL :\n";
echo "link1 : "; var_dump($link1);
echo "link2 : "; var_dump($link2);
echo 'mysql thread : '.mysql_thread_id($link2)."\n";

// oops $link2 is no more usable to do queries,
// that's a bug for me !
mysql_query('select * from user',$link2); // line 28

?>

generate this output :

link1 : resource(4) of type (mysql link)
link2 : resource(4) of type (mysql link)
mysql thread : 16
-- after closing link1 :
link1 : resource(4) of type (mysql link)
link2 : resource(4) of type (mysql link)
mysql thread : 16
-- after link1 = NULL :
link1 : NULL
link2 : resource(4) of type (Unknown)
Warning: mysql_thread_id(): 4 is not a valid MySQL-Link resource in ...
on line 24
mysql thread : 
Warning: mysql_query(): 4 is not a valid MySQL-Link resource in ... on
line 28


If you could please answer this one last question :

why does affecting "NULL" to $link1 make $link2 to become "Unkown"  ?
In other words, why don't we see this output instead :

link1 : resource(4) of type (mysql link)
link2 : resource(4) of type (mysql link)
mysql thread : 16
-- after closing link1 :
link1 : resource(4) of type (Unknown)
link2 : resource(4) of type (mysql link)
mysql thread : 16
-- after link1 = NULL :
link1 : NULL
link2 : resource(4) of type (mysql link)
mysql thread : 16


If this is a feature than it should be documented as it is not obvious
that changing the value of the resource variable will close the
connection, even if it has been closed before.

-- 
Edit this bug report at http://bugs.php.net/?id=32866&edit=1

Reply via email to