Bug #14216: odbc_tables() does not close automatically ODBC MSAccess connection
| From: | astelix at libero dot it | Date: | Sun, 25 Nov 2001 12:20:14 +0000 |
| Subject: | Bug #14216: odbc_tables() does not close automatically ODBC MSAccess connection | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-71592@lists.php.net to get a copy of this message | ||
From: astelix@libero.it
Operating system: Windows 2000
PHP version: 4.0.6
PHP Bug Type: ODBC related
Bug description: odbc_tables() does not close automatically ODBC MSAccess connection
This is a bug report and, i think, also a solution report. If u use the
canonical syntax to retrieve table names from a Microsoft Access ODBC
connection on windows 2K (dunno if this happen with previous versions)
using ZEND PHP 4.0.6 engine, you will see your page to fall in a deep
endless loop without waking up. The workaround, that is also a good coding
practice, is to close all you left open: so use odbc_close_all() and your
sleepy page turn to wake up without a prob!
Here it is my piece of code to accomplish the whole job:
<script language="php">
//
// ODBC database table names retrieve with odbc_tables()
//
error_reporting (E_ALL);
$the_connection="test";
$ODBCConn=odbc_connect($the_connection, "", "",SQL_CUR_USE_ODBC) or
die("DSN error!");
$i=0;
$recordset=odbc_tables($ODBCConn);
while(odbc_fetch_row($recordset))
{
// In MSAccess the first 5 tables are used by the application and we
don't care of them
if (++$i <= 5) echo ":: SYSTEM TABLE :: ";
echo odbc_result($recordset, "TABLE_NAME")."<br>\n";
}
flush(); // this is merely optional
odbc_close_all(); // don't forget this!!!
</script>
--
Edit bug report at: http://bugs.php.net/?id=14216&edit=1