supportsTransactionalDDL example

// Create the dedicated field tables using "deleted" table names.       foreach ($dedicated_table_field_schema as $name => $table) {
        if (!$this->database->schema()->tableExists($dedicated_table_name_mapping[$name])) {
          $this->database->schema()->createTable($dedicated_table_name_mapping[$name]$table);
        }
        else {
          throw new EntityStorageException('The field ' . $storage_definition->getName() . ' has already been deleted and it is in the process of being purged.');
        }
      }

      try {
        if ($this->database->supportsTransactionalDDL()) {
          // If the database supports transactional DDL, we can go ahead and rely           // on it. If not, we will have to rollback manually if something fails.           $transaction = $this->database->startTransaction();
        }

        // Copy the data from the base table.         $this->database->insert($dedicated_table_name)
          ->from($this->getSelectQueryForFieldStorageDeletion($field_table_name$shared_table_field_columns$dedicated_table_field_columns))
          ->execute();

        // Copy the data from the revision table.
$transaction2 = $this->connection->startTransaction();
    $this->executeDDLStatement();
    unset($transaction2);
    $transaction3 = $this->connection->startTransaction();
    $this->insertRow('row');
    $transaction3->rollBack();
    unset($transaction3);
    unset($transaction);
    $this->assertRowAbsent('row');

    // The behavior of a rollback depends on the type of database server.     if ($this->connection->supportsTransactionalDDL()) {
      // For database servers that support transactional DDL, a rollback       // of a transaction including DDL statements should be possible.       $this->cleanUp();
      $transaction = $this->connection->startTransaction();
      $this->insertRow('row');
      $this->executeDDLStatement();
      $transaction->rollBack();
      unset($transaction);
      $this->assertRowAbsent('row');

      // Including with stacking.
Home | Imprint | This part of the site doesn't use cookies.