ID:               36910
 Comment by:       lars dot westermann at privat dot dk
 Reported By:      arnoldvmartinez at yahoo dot com
 Status:           No Feedback
 Bug Type:         InterBase related
 Operating System: Windows 2003
 PHP Version:      5.1.2
 New Comment:

This has to do with the transaction handling of Interbase/Firebird.

Taking the first example:

The first SELECT uses the default transaction (taking a "snapshot" of
the database).
Then a NEW transaction is created (unseen by the default transaction)
A record is inserted, and the transaction is closed.
The next select STILL operates on the DEFAULT transaction, which was
opened prior to the transaction, where the record was inserted -
therefore the newly inserted record is not found.

The solution is to ALWAYS use explicit transactions - and NEVER use the
default transaction.

You *might* want to fiddle with the transaction type (snapshot,
read_commited etc.) but beware, that this can have a dramtic effect on
performance on large databases.

Personally I always start a transaction - even for a single select.

This "bug" therefore isn't a bug, neither in PHP nor in Firebird.

/Lars


Previous Comments:
------------------------------------------------------------------------

[2006-04-27 07:26:27] kogut at kogumelo dot com dot br

I'm not the owner of this bug, but i´ve got the same problem.

In my situation, as opposed to what the manual says, changing
"$sth=ibase_query($th,$stmt)" to "$sth=ibase_query($dbh,$stmt)" just
after the "insert ... " statement and "ibase_commit($th)" to
"ibase_commit($dbh)" makes it work for me. And if i change to
"ibase_rollback($dbh)", it works fine, too.  I don´t know if it is a Php
or a Firebird bug, but that´s weird.

------------------------------------------------------------------------

[2006-04-06 01:00:00] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

------------------------------------------------------------------------

[2006-03-29 13:41:32] [EMAIL PROTECTED]

And why did you decide it's a problem of PHP?
Are you able to get the expected result using some other tool?

------------------------------------------------------------------------

[2006-03-29 13:08:36] arnoldvmartinez at yahoo dot com

$dbh = ibase_connect($host, $user, $password);
$stmt = 'SELECT * FROM Employees';
$sth = ibase_query($dbh, $stmt);
while ($row = ibase_fetch_object($sth)) {
       echo '<br>'.$row->EMPNAME;
}
$th=ibase_trans(IBASE_DEFAULT,$dbh);
$stmt='INSERT statement here...';
$sth = ibase_query($th, $stmt);
ibase_commit($th);
$stmt = 'SELECT * FROM Employees';
$sth = ibase_query($dbh, $stmt);
while ($row = ibase_fetch_object($sth)) {
       echo '<br>'.$row->EMPNAME;
}
/* new record not listed */

------------------------------------------------------------------------

[2006-03-29 12:55:24] [EMAIL PROTECTED]

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.



------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/36910

-- 
Edit this bug report at http://bugs.php.net/?id=36910&edit=1

Reply via email to