Subject RE: [firebird-php] Is transaction correct ?
Author Alan McDonald
I think it depends on what type of scripting you are doing. I use it with a
webserver and it's all page based. I don't need to specify a transaction
since every page has it's own transaction context.
every time I call an ibase_query function, the function returns true is
successfull and no errors occurred.
So if I reach the point after serveral queries (e.g. updates, selects, etc)
where I need to decide, the I just examine the retun values
$myreturn = @ibase_query( etc
$mysecondreturn = @ibase_query( another statement)
now at the time I need to decide to commit or rollback I do this

if ($myreturn &&$mysecondreturn) {
header("Location: a page I want to go when everything is OK);
} else {
if (!$myreturn) echo "<font color='red'>There has been an
<b>error</b> inserting the [first] as supplied, please try again and/or use
the etc, etc.</font>";
if (!$mysecondreturn) echo "<font color='red'>There has been an
<b>error</b> inserting the [second record] as supplied, please try again
and/or use the etc </font>";

PS. In the odd event that you need a second transaction on the same page,
then you will have to start one manually.
-----Original Message-----
From: []On
Behalf Of Uwe Oeder
Sent: Monday, 13 June 2005 5:42 PM
Subject: [firebird-php] Is transaction correct ?

Is the following the correct way to start a transaction and roll it back
if something goes wrong or is incorrect.
If any exception is raised I let the exception handler catch it and
rollback any changes.

$this->mydbhandle =
ibase_connect($this->myhost,$this->myusername,$this->mypassword) ;
$this->mytransaction = ibase_trans() ;
foreach ($updatedata as $mydata)
$mydbquery = ibase_prepare($this->mydbhandle,$sqlstatement) ;
$rowsaffected = ibase_execute($this->mydbquery) ;
ibase_commit($this->mydbhandle) ;
ibase_free_query($this->mydbquery) ;
ibase_close($this->mydbhandle) ;
catch (Exception $e)
ibase_rollback($this->mytransaction) ;

Yahoo! Groups Links

a.. To visit your group on the web, go to:

b.. To unsubscribe from this group, send an email to:

c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

[Non-text portions of this message have been removed]