我刚刚打开提交了一个与postgres数据库连接相关的bug任何可以帮助避免这种情况的.ini设置。
<?php
$dbLink1 = pg_connect( "host=localhost port=5432 dbname=development", PGSQL_CONNECT_FORCE_NEW );
pg_query($dbLink1, 'select 1; /*FIRST*/');
$dbLink2 = pg_connect( "host=localhost port=5432 dbname=development", PGSQL_CONNECT_FORCE_NEW );
pg_query($dbLink2, 'select 1; /*SECOND*/');
/*closing first link*/
pg_close($dbLink1);
$dbLink2 = pg_connect( "host=localhost port=5432 dbname=development", PGSQL_CONNECT_FORCE_NEW );
pg_query($dbLink2, 'select 1; /*THIRD*/');
/*2nd 3rd connection remain idle on the database connection as long as the scripts is alive, the 2nd connection overridden by $dbLink2 should be automatically destroyed*/
sleep(200); ?>
在 PHP 5.6、5.5 上,我注意到所有未使用的连接都会自动清理,并且我在数据库上只剩下 1 个空闲连接,这在 PHP 7 中似乎并非如此。