disconnect 使 1 个活动语句句柄无效(在断开连接之前销毁语句句柄或调用完成)
以下从 MySQL 获取数据的代码成功执行,但会导致 Apache 在其错误日志中生成上述消息:
my $driver = "mysql";
my $server = "localhost:3306";
my $database = "test";
my $url = "DBI:$driver:$database:$server";
my $user = "apache";
my $password = "";
#Connect to database
my $db_handle = DBI->connect( $url, $user, $password )
or die $DBI::errstr;
#SQL query to execute
my $sql = "SELECT * FROM tests WHERE id=?";
#Prepare SQL query
my $statement = $db_handle->prepare($sql)
or die "Couldn't prepare query '$sql': $DBI::errstr\n";
#Execute SQL Query
$statement->execute($idFromSomewhere)
or die "Couldn't execute query '$sql': $DBI::errstr\n";
#Get query results as hash
my $results = $statement->fetchall_hashref('id');
$db_handle->disconnect();
忽略上述错误/警告会产生任何可怕的后果吗?该代码已经运行了一周,没有任何不良影响。
代码有什么问题还是这只是一个无害的警告?
编辑
代码通过 mod_perl 执行。