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

 ID:                 46182
 Comment by:         ninzya at inbox dot lv
 Reported by:        ninzya at inbox dot lv
 Summary:            mysql_connection_reused( $link) function
 Status:             Wont fix
 Type:               Feature/Change Request
 Package:            MySQL related
 Operating System:   Any
 PHP Version:        5.3.0alpha2
 Assigned To:        mysql
 Block user comment: N
 Private report:     N

 New Comment:

Thank you for the info.


Previous Comments:
------------------------------------------------------------------------
[2011-01-06 16:06:17] u...@php.net

Reusing of not properly cleaned up persistent connections is an evil
aside effect that's confusing many beginners. mysqli gives you the
choice if you want connections that are put into the persistent pool
always to be cleaned up  and appear as if they had been just opened
(default) or to return them in the state the previous user as left them
when the connection was put into the persistent pool - with all the
dirty side effects: authentication changes are not detected,
transactions can be open, variables are not cleared up, temporary tables
are there etc. . mysqli makes a clear cut and calls mysql_change_user()
(C API = mysqli_change_user() PHP mysqli) before reusing a connection.
Its always cleaned up. That's a safe choice for 90% of the users. Only
some power users who know what they do should require the ext/mysql
behaviour. And those power users don't need an extra API call because
you can hack something using SQL connection variables:



SELECT @connection_init

if @connection_init = 0

  INIT stuff

  SET @connection_init = 1

------------------------------------------------------------------------
[2008-09-26 13:24:06] ninzya at inbox dot lv

Description:
------------
It would be great if we had mysql_connection_reused( $link) function, 

which returned boolean value if just established connection was 

reused or no.

Reproduce code:
---------------
$link =mysql_pconnect( $host .':' .$port, $user, $pass);

if( !mysql_connection_reused( $link)) {

  mysql_query( 'SET NAMES utf8;');

  mysql_query( 'USE mydb;');

} else {

  // connection was reused, don't do any initialization queries,

  //  because they were already made by another request

}

Expected result:
----------------
This would allow to optimize database load on heavy loaded servers.

Actual result:
--------------
Not implemented


------------------------------------------------------------------------



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

Reply via email to