note 50571 added to function.odbc-connect
| From: | aamaral at 0kbps dot net | Date: | Thu, 03 Mar 2005 18:16:38 +0000 |
| Subject: | note 50571 added to function.odbc-connect | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-85881@lists.php.net to get a copy of this message | ||
Two additional notes regarding ODBC connections to a Network Sybase SQL Anywhere 8 Server..
I wrote a script using the PHP5 CLI binary that monitors a directory for changes, then updates a
Network Server SQL Anywhere 8 database when a change was detected. Idealy, my program would run
indefinately, and issue odbc_connect()/odbc_close() when appropriate. However, it seems that once
connected, your odbc session is limited to 30 seconds of active time, after which, the connection
becomes stale, and no further queries can be executed. Instead, it returns a generic
"Authentication violation" error from the odbc driver.
Here's an example:
<?php
$conn=odbc_connect($connect_string,'','');
$result=odbc_exec($qry,$conn); //returns data
sleep(31);
$result=odbc_exec($qry,$conn); //"Authentication Violation"
?>
Additionally, it seems that odbc_close() doesn't truely close the connection (at least not
using Network SQL Anywhere 8). The resource is no longer usable after the odbc_close() is issued,
but as far as the server is concerned, there is still a connection present. The connection
doesn't truely close until after the php script has ended, which is unfortunate, because a
subsequent odbc_connect() commands appear to reuse the existing stale connection, which was
supposedly closed.
My workaround was to design my script exit entirely after a the database update had completed. I
then called my script whithin a batch file and put it inside an endless loop.
I'm not sure if this is a bug with PHP or what, but I thought I'd share in case someone
else is pulling their hair out trying to figure this one out...
----
Manual Page -- http://www.php.net/manual/en/function.odbc-connect.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+50571
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50571&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50571&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50571&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50571&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50571&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+50571&report=yes
Search -- http://master.php.net/manage/user-notes.php