Get Started

Medoo 1.4

Where Syntax

Query

Fetch

Transaction

Advanced

PDO object

Debug

Information

version: 1.4.5

action

Start a transaction

action($callback)
Return: void
Not every database or database engine supports transactions. You have to check before using it. All queries will be automatically committed inside the transaction wrap. You can also return false value to rollback the transactions.
$database->action(function($database) {
	$database->insert("account", [
		"name" => "foo",
		"email" => "bar@abc.com"
	]);

	$database->delete("account", [
		"user_id" => 2312
	]);

	// If you find something wrong, just return false to rollback the whole transaction.
	if ($database->has("post", ["user_id" => 2312]))
	{
		return false;
	}
});