Re: Informix ifx_close

From: Date: Wed, 24 Jul 2002 10:36:44 +0000
Subject: Re: Informix ifx_close
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-20745@lists.php.net to get a copy of this message
Hello, On 07/24/2002 06:50 AM, Martins Junkers wrote:
I have following script: <? $db=ifx_connect("db","uid","pwd"); $result=ifx_query("begin work",$db); $result=ifx_query("insert into m_test1 (i) values('1');", $db); $result=ifx_query("select * from m_test1;", $db); while($row=ifx_fetch_row($result)) {
        echo($row['i']);
} $result=ifx_query("rollback work;", $db); echo("rollback"); $result=ifx_query("select * from m_test1;", $db); while($row=ifx_fetch_row($result)) {
        echo($row['i']);
} ifx_close($db); ?> If i dont execute $result=ifx_query("rollback work;", $db); and just call ifx_close session is not closed and autmatic rollback is not execute (as it must be) but connection to Informix database stays with lock on this row. Usualy you must have rollback or commit; But to avoid problems with bad code or other coding probs after calling ifx_close() session must be rolled back and closed. What is solution for this case?
By definition transactions are rolled back if a database session is discontinued for whatever reasons. You would have a problem if the connection was persistent though. The solution used in Metabase is to register a shutdown procedure to rollback any pending transactions explicitly at the script exit. The solution is database independent, so it works with Informix too. Take a look: http://www.phpclasses.org/metabase -- Regards, Manuel Lemos

« previous php.db (#20745) next »