php教程

odbc_close

(PHP 4, PHP 5, PHP 7)

odbc_closeClose an ODBC connection

说明

odbc_close ( resource $connection_id ) : void

Closes down the connection to the database server.

参数

connection_id

ODBC 连接标识符,详见 odbc_connect()

返回值

没有返回值。

注释

Note:

This function will fail if there are open transactions on this connection. The connection will remain open in this case.

User Contributed Notes

alvaro at demogracia dot com 26-Mar-2018 10:33
`odbc_close()` does not report success and some drivers (namely Microsoft Access) don't seem to close connections at first attempt. This is normally not an issue, unless you need to establish many connections within the script lifetime.

You can use the fact that resource type changes (e.g. from "odbc link" to "Unknown") as a trick to figure out whether connection was successfully closed (and eventually retry):

<?php
$type
= get_resource_type($conn);
$wait_until = time() + 3;
do {
   
odbc_close($conexion_odbc);
} while (
get_resource_type($conn)===$type && time()<$wait_until);
mallsop at ind dot net 16-May-2000 07:33
On microsoft servers, use the odbc_free_result command.

CopyRight © 2008-2022 verySource.Com All Rights reserved. 京ICP备17048824号-1 京公网安备:11010502034788