#42 CompleteTrans() not working properly

Next_Version
closed
5
2006-04-29
2006-02-18
No

It seems that CompleteTrans() is not working properly.
It returns true even if an error occured on a way. The
following code:

/* update database */
$db->debug = true;
$db->StartTrans();
$db->Execute(sprintf('UPDATE bt_users SET
points=points+%d WHERE id=%d', $points,
$_SESSION['user']));
$db->Execute(sprintf('INSERT INTO bt_user_accounts
VALUES (%d, %d, %s, %s)', $_SESSION['user'], $points,
$db->qstr(date(DB_TIMESTAMP_FORMAT)),
$db->qstr("Zasilenie konta przez SMS")));
$db->Execute(sprintf('INSERT INTO bt_payments_sms
(user_id, code, amount, time) VALUES (%d, %s, %d, %s)',
$_SESSION['user'], $db->qstr($_POST['code']),
payment_package_to_amount($_POST['package']) * 100,
$db->qstr(date(DB_TIMESTAMP_FORMAT))));
if ($db->CompleteTrans() !== true)
{
$this->abort_error(ERRTXT_DB_QUERY);
}

results in:

(postgres8): UPDATE bt_users SET points=points+514
WHERE id=1
Error (0):

(postgres8): INSERT INTO bt_user_accounts VALUES (1,
514, '2006-02-18 11:37:07', 'Zasilenie konta przez SMS')
Error (0):

(postgres8): INSERT INTO bt_payments_sms (user_id,
code, amount, time) VALUES (1, 'WYB2K123', 36,
'2006-02-18 11:37:07')
Error (ERROR: null value in column "id" violates
not-null constraint): ERROR: null value in column "id"
violates not-null constraint

(postgres8): Smart Commit occurred
Error (0):

Discussion

  • Matt Sicker

    Matt Sicker - 2006-03-14

    Logged In: YES
    user_id=1088943

    Hmm, this problem happened to me using the
    mysqli+transactions module. I'm confirming this as well.

     
  • Mark Dickenson

    Mark Dickenson - 2006-04-14

    Logged In: YES
    user_id=752816

     
  • Mark Dickenson

    Mark Dickenson - 2006-04-14
    • status: open --> pending
     
  • SourceForge Robot

    • status: pending --> closed
     
  • SourceForge Robot

    Logged In: YES
    user_id=1312539

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).

     
  • Tudor Vaida

    Tudor Vaida - 2006-05-23

    Logged In: YES
    user_id=140039

    Confirming for mysql/mysqli, problem is object's member
    transaction_status never gets false after an invalid Execute
    during the transaction.

     

Log in to post a comment.