Medoo

开始

Where 语句

查询

Transaction

原生SQL查询

PDO object

Debug

数据库信息

PDO Object

Medoo是一个基于PDO的项目.你通过 $database->pdo, 能够使用更多的PDO方法, 预定义,事务 , 回滚 等.
更多关于 PDO 的使用, 请阅读: 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();

Prepare

有时候Medoo不能处理一些复杂的PDO时,你可以使用它来完成.
$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();
>