[drupal8]Drupal db_transaction 使用范式详解

时间:2020-11-27  来源:Action  阅读:

$transaction = isset($transaction) ? $transaction : db_transaction();
 
try {
  $ids = array_keys($entities);
 
  db_delete($this->entityInfo["base table"])
    ->condition($this->idKey, $ids, "IN")
    ->execute();
 
  if (isset($this->revisionTable)) {
    db_delete($this->revisionTable)
      ->condition($this->idKey, $ids, "IN")
      ->execute();
  }
  // Reset the cache as soon as the changes have been applied.
  $this->resetCache($ids);
 
  foreach ($entities as $id => $entity) {
    $this->invoke("delete", $entity);
  }
  // Ignore slave server temporarily.
  db_ignore_slave();
}
catch (Exception $e) {
  $transaction->rollback();
  watchdog_exception($this->entityType, $e);
  throw $e;
}

以上代码片段为使用db_transaction范式。摘抄自entity模块。

 

[drupal8]Drupal db_transaction 使用范式详解

http://m.bbyears.com/flash/113039.html

推荐访问:drupal教程 drupal_add_css drupal表单
相关阅读 猜你喜欢
本类排行 本类最新