PHP mysqli_release_savepoint() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
MySQLi

Definition

In PHP, mysqli_release_savepoint() removes a named savepoint from the current transaction without rolling the transaction back.

It belongs to the transaction family with begin_transaction(), savepoint(), rollback(), and commit(). After release, that savepoint name is no longer a rollback target. The surrounding transaction stays open until you commit or roll back.

Syntax

Call mysqli_release_savepoint() with the values you need. Start with this line.

PHP
$ok = mysqli_release_savepoint($mysql, 'sp1');
CallWhat it does
mysqli_release_savepoint($link, 'after_insert')Drops the named savepoint if it exists in the open transaction.
$mysqli->release_savepoint('sp1')Object-oriented form with the savepoint name.
mysqli_rollback($link, 0, 'sp1')Contrast: rollback to a savepoint undoes work; release only removes the marker.

Call this only inside an open transaction after mysqli_savepoint(). Releasing does not undo SQL you already ran. Use rollback() with a name when you need to undo back to that marker.

Library declarations
PHP
mysqli_release_savepoint(mysqli $mysql, string $name): bool

Parameters

ParameterDescription
mysqlRequired. Procedural style only: a mysqli connection inside a transaction.
nameRequired. The savepoint identifier previously created with mysqli_savepoint().

Return Value

Return ValueDescription
trueThe savepoint was released.
falseRelease failed (bad name, no transaction, or server error).

PHP Examples

Example 1 — Release a Named Savepoint

Walk through begin → savepoint → release with fixed demo status lines.

PHP
<?php
$steps = ['begin_transaction', 'savepoint sp1', 'release_savepoint sp1'];
foreach ($steps as $step) {
    echo $step, ': ok', PHP_EOL;
}

How It Works

  1. Start a transaction with begin_transaction() or similar.
  2. Create a marker with savepoint('sp1').
  3. release_savepoint('sp1') removes that marker only.
  4. Sample output when connected to a demo database would show each call returning true.

Example 2 — Release vs Rollback to Savepoint

Compare the two different outcomes in plain text.

PHP
<?php
echo "release_savepoint('sp1') -> keep work, drop marker", PHP_EOL;
echo "rollback(..., 'sp1')     -> undo work after marker", PHP_EOL;

How It Works

  1. Release keeps the SQL you already ran.
  2. Named rollback undoes changes after the savepoint.
  3. Both need an open transaction and a valid name.
  4. Finish with commit() or a full rollback() when the unit of work ends.

Example 3 — Procedural Call Pattern

Show the function arguments you will write in real code.

PHP
<?php
$link = 'mysqli-link';
$name = 'sp_checkout';
echo 'mysqli_release_savepoint($link, ', var_export($name, true), ')', PHP_EOL;

How It Works

  1. Procedural style needs the connection handle first.
  2. The second argument is the exact savepoint name string.
  3. OO style is $mysqli->release_savepoint($name).
  4. Check the boolean return and mysqli_error() on failure.

Frequently Asked Questions

It removes a named savepoint from the current transaction without rolling back any changes.
rollback() undoes work (optionally to a savepoint). release_savepoint() only deletes the savepoint name.
begin_transaction(), savepoint(), rollback(), commit(), and sometimes autocommit().
You can no longer roll back to that name, but the transaction continues until commit or rollback.
true on success and false on failure.

Next: mysqli_rollback()

mysqli_rollback() undoes the current transaction so none of its uncommitted changes stay o.

mysqli_rollback() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful