0

I am new to drupal. In an attempt to achieve transaction, I get this fatal error. I am using drupal 6.22 and MySQL. db_query() and all the other database related functions are working fine, but db_transaction() alone fails. What am I doing wrong here? Any help is appreciated.

$transaction = db_transaction();

try {
       $result = db_query($query);
}
catch (Exception $e) {
       $transaction->rollback();

}
3

There is no fuction db_transaction() for Drupal 6 (see Drupal 6 API search).

It is available for Drupal 7 though: db_transaction()

  • so, is there any way to achieve transaction in drupal 6? – Vivek Jan 20 '12 at 18:54
  • Yes, as mentioned by Berdir in his answer – Laxman13 Feb 11 '12 at 17:19
2

The DB API in Drupal 6 does not have support for transactions.

You can however use the Backport of the Drupal 7 DB API: http://drupal.org/project/dbtng

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.