0

The problems I am trying to solve are:

1- How can I connect tables defined by $schema to each other?

2- How do you insert data consistently into the database? Is there any possibility of having Transaction facilities in Drupal? (I know how to do it in mySQL, but I'm looking for something built-in for Drupal Core.)

Thank you so much

1 Answer 1

0

How can I connect tables defined by $schema to each other?

I'm not sure what you mean by that, but possibly you're asking how to describe relationships between tables to the Schema API? Drupal has no support for that currently; there is a foreign keys property available, but:

Foreign key definitions were added in Drupal 7 for documentation purposes only, and do not modify the database.


How do you insert data consistently into the database? Is there any possibility of having Transaction facilities in Drupal?

Yes, Drupal supports transactions. The API method to use is db_transaction():

$transaction = db_transaction();

try {
  db_update('foo')...;
}
catch (Exception $e) {
  $transaction->rollback();
  // Recover
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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