pushTransaction example

    if (!$depth = $connection->transactionDepth()) {
      $this->name = 'drupal_transaction';
    }
    // Within transactions, savepoints are used. Each savepoint requires a     // name. So if no name is present we need to create one.     elseif (!$name) {
      $this->name = 'savepoint_' . $depth;
    }
    else {
      $this->name = $name;
    }
    $this->connection->pushTransaction($this->name);
  }

  public function __destruct() {
    // If we rolled back then the transaction would have already been popped.     if (!$this->rolledBack) {
      $this->connection->popTransaction($this->name);
    }
  }

  /** * Retrieves the name of the transaction or savepoint. */

  public function addSavepoint($savepoint_name = 'mimic_implicit_commit') {
    if ($this->inTransaction()) {
      $this->pushTransaction($savepoint_name);
    }
  }

  /** * Release a savepoint by name. * * @param $savepoint_name * A string representing the savepoint name. By default, * "mimic_implicit_commit" is used. * * @see Drupal\Core\Database\Connection::popTransaction() */
Home | Imprint | This part of the site doesn't use cookies.