note 19122 modified in function.ocilogoff by sixd
| From: | sixd@php.net | Date: | Mon, 05 Oct 2009 01:41:40 +0000 |
| Subject: | note 19122 modified in function.ocilogoff by sixd | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-161305@lists.php.net to get a copy of this message | ||
For using persistent connections && being able to sleep, I use:
function close_db_locks_on_abort( ) {
global $conn;
if( connection_aborted() ) {
$fp = fopen( "/tmp/shutdown-func.txt", "a" );
fwrite( $fp, sprintf( "connection aborted on %s\n", date( "d-m-Y H:i:s" ) ) );
if( $conn ) {
OCIRollBack( $conn );
fwrite( $fp, sprintf( "-- DURING CONNECTION! ip=%s, user=%s, page=%s\n",
$_SERVER["REMOTE_ADDR"], $_SERVER["PHP_AUTH_USER"],
$_SERVER["SCRIPT_FILENAME"] ) );
}
fclose( $fp );
}
}
register_shutdown_function ( "close_db_locks_on_abort" );
This makes sure a rollback is done on a connection when a user hits 'stop', so there will
be no locks on table rows.
--was--
For using persistent connections && being able to sleep, I use:
function close_db_locks_on_abort( ) {
global $conn;
if( connection_aborted() ) {
$fp = fopen( "/tmp/shutdown-func.txt", "a" );
fwrite( $fp, sprintf( "connection aborted on %s\n", date( "d-m-Y H:i:s" ) ) );
if( $conn ) {
OCIRollBack( $conn );
fwrite( $fp, sprintf( "-- DURING CONNECTION! ip=%s, user=%s, page=%s\n",
$_SERVER["REMOTE_ADDR"], $_SERVER["PHP_AUTH_USER"],
$_SERVER["SCRIPT_FILENAME"] ) );
}
fclose( $fp );
}
}
register_shutdown_function ( "close_db_locks_on_abort" );
This makes sure a rollback is done on a connection when a user hits 'stop', so there will
be no locks on table rows.
http://php.net/manual/en/function.ocilogoff.php