Get Started

Medoo 1.4

Where Syntax

Query

Fetch

Transaction

Advanced

PDO object

Debug

Information

version: 1.4.5

PDO object

Medoo is based on PDO object. You can access the PDO object directly via using $database->pdo, so that you can use all PDO functions if you needed, like prepare, transaction, rollBack or more.

For more information about PDO class, read more about from: http://php.net/manual/en/class.pdo.php.

Transaction

$database->pdo->beginTransaction();

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

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

/* Recognize mistake and roll back changes */
$database->pdo->rollBack();

Prepared Statement

Sometime, if Medoo cannot process complex SQL query, you can use it like a PDO wrapper with PDO internal functions to process the query in case of 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();