odbc_close

(PHP 4, PHP 5, PHP 7, PHP 8)

odbc_closeODBC 接続を閉じる

説明

odbc_close(resource $odbc): void

指定された接続 ID が指すデータベースサーバーへの接続を閉じます。

パラメータ

odbc

ODBC 接続 ID。詳細は odbc_connect() を参照ください。

戻り値

値を返しません。

注意

注意:

この関数の処理は、この接続に関してオープンされたトランザクションがある場合に失敗します。 この場合、接続はオープンされたままとなります。

add a note add a note

User Contributed Notes 1 note

up
-2
alvaro at demogracia dot com
5 years ago
`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);
To Top