EN English
Version: v2.4.0

PDO Object

Medoo is built on PDO. You can access the PDO instance directly through $database->pdo, which lets you use native PDO methods such as prepare(), beginTransaction(), and rollBack().
For more information about PDO, see: https://php.net/manual/en/class.pdo.php.

Transaction

$database->pdo->beginTransaction();

$database->insert("account", [
	"user_name" => "foo",
	"email" => "foo@bar.com",
	"age" => 25
]);

/* Commit changes. */
$database->pdo->commit();

/* If needed, roll back changes. */
$database->pdo->rollBack();

Prepared Statement

If Medoo syntax does not fit a complex query, you can use PDO prepared statements directly through $database->pdo to keep queries safe from SQL injection.
$calories = 150;
$colour = 'red';

$sth = $database->pdo->prepare('SELECT name, colour, calories
	FROM fruit
	WHERE calories < :calories AND colour = :colour');

$sth->bindParam(':calories', $calories, PDO::PARAM_INT);
$sth->bindParam(':colour', $colour, PDO::PARAM_STR, 12);

$sth->execute();