releaseSavepoint example


  public function execute() {
    $this->connection->addSavepoint();
    try {
      $result = parent::execute();
    }
    catch (\Exception $e) {
      $this->connection->rollbackSavepoint();
      throw $e;
    }
    $this->connection->releaseSavepoint();

    return $result;
  }

}
// Create a savepoint so we can rollback a failed query. This is so we can     // mimic MySQL and SQLite transactions which don't fail if a single query     // fails. This is important for tables that are created on demand. For     // example, \Drupal\Core\Cache\DatabaseBackend.     $this->connection->addSavepoint();
    try {
      $stmt->execute(NULL, $this->queryOptions);
      if (isset($table_information->serial_fields[0])) {
        $last_insert_id = $stmt->fetchField();
      }
      $this->connection->releaseSavepoint();
    }
    catch (\Exception $e) {
      $this->connection->rollbackSavepoint();
      $this->connection->exceptionHandler()->handleExecutionException($e$stmt[]$this->queryOptions);
    }

    // Re-initialize the values array so that we can re-use this query.     $this->insertValues = [];

    return $last_insert_id ?? NULL;
  }

  
$this->condition->compile($this->connection, $this);

      $arguments = $this->condition->arguments();
      foreach ($arguments as $placeholder => $value) {
        $stmt->getClientStatement()->bindParam($placeholder$arguments[$placeholder]);
      }
    }

    $this->connection->addSavepoint();
    try {
      $stmt->execute(NULL, $this->queryOptions);
      $this->connection->releaseSavepoint();
      return $stmt->rowCount();
    }
    catch (\Exception $e) {
      $this->connection->rollbackSavepoint();
      $this->connection->exceptionHandler()->handleExecutionException($e$stmt[]$this->queryOptions);
    }
  }

}

  public function execute() {
    $this->connection->addSavepoint();
    try {
      $result = parent::execute();
    }
    catch (\Exception $e) {
      $this->connection->rollbackSavepoint();
      throw $e;
    }
    $this->connection->releaseSavepoint();

    return $result;
  }

}
// Re-initialize the values array so that we can re-use this query.     $this->insertValues = [];

    // Create a savepoint so we can rollback a failed query. This is so we can     // mimic MySQL and SQLite transactions which don't fail if a single query     // fails. This is important for tables that are created on demand. For     // example, \Drupal\Core\Cache\DatabaseBackend.     $this->connection->addSavepoint();
    try {
      $stmt->execute(NULL, $options);
      $this->connection->releaseSavepoint();
      return $stmt->rowCount();
    }
    catch (\Exception $e) {
      $this->connection->rollbackSavepoint();
      $this->connection->exceptionHandler()->handleExecutionException($e$stmt[]$options);
    }
  }

  /** * {@inheritdoc} */
  
EOD;
        $result = $this->connection->query($sql[
          ':key' => $quoted_key,
        ]);
      }
      catch (\Exception $e) {
        $this->connection->rollbackSavepoint();
        throw $e;
      }
      $this->connection->releaseSavepoint();

      // If the table information does not yet exist in the PostgreSQL       // metadata, then return the default table information here, so that it       // will not be cached.       if (empty($result)) {
        return $table_information;
      }

      foreach ($result as $column) {
        if ($column->data_type == 'bytea') {
          $table_information->blob_fields[$column->column_name] = TRUE;
        }

  public function execute() {
    $this->connection->addSavepoint();
    try {
      $result = parent::execute();
    }
    catch (\Exception $e) {
      $this->connection->rollbackSavepoint();
      throw $e;
    }
    $this->connection->releaseSavepoint();

    return $result;
  }

}

/** * @} End of "addtogroup database". */
stripos($query, 'SAVEPOINT ') === 0
      )
    );
    if ($wrap_with_savepoint) {
      // Create a savepoint so we can rollback a failed query. This is so we can       // mimic MySQL and SQLite transactions which don't fail if a single query       // fails. This is important for tables that are created on demand. For       // example, \Drupal\Core\Cache\DatabaseBackend.       $this->addSavepoint();
      try {
        $return = parent::query($query$args$options);
        $this->releaseSavepoint();
      }
      catch (\Exception $e) {
        $this->rollbackSavepoint();
        throw $e;
      }
    }
    else {
      $return = parent::query($query$args$options);
    }

    return $return;
  }
Home | Imprint | This part of the site doesn't use cookies.