Medoo介绍
Medoo是一款超轻量级的PHP SQL数据库框架,由社交网站Catfan和开源项目Qatrix的创始人黎言卓开发。提供了简单,易学,灵活的API,提升开发Web应用的效率与性能,而且体积只有8KB不到。
特性
轻量级,只有一个文件
简单易学,数据结构一目了然
支持多种SQL语法,以及支持复杂的查询条件
支持多种数据库,包括MySQL, MSSQL, SQLite等等
安全,可防止SQL注入
免费,基于MIT协议
示例代码
增加
复制代码 代码如下:
$database = new medoo ( "my_database" );
$last_user_id = $database->insert ( "account", [
"user_name" => "foo",
"email" => "foo@bar.com",
"age" => 25,
"lang" => [
"en",
"fr",
"jp",
"cn"
]
] );
删除
复制代码 代码如下:
$database = new medoo ( "my_database" );
$database->delete("account", [
"AND" => [
"type" => "business"
"age[ 18
]
]);
修改
复制代码 代码如下:
$database = new medoo ( "my_database" );
$database->update ( "account", [
"type" => "user",
// All age plus one
"age[+]" => 1,
// All level subtract 5
"level[-]" => 5,
"lang" => [
"en",
"fr",
"jp",
"cn",
"de"
]
], [
"user_id[ 1000
] );
查询
复制代码 代码如下:
$database = new medoo ( "my_database" );
$datas = $database->select ( "account", [
"user_name",
"email"
], [
"user_id[>]" => 100
] );
// $datas = array(
// [0] => array(
// "user_name" => "foo",
// "email" => "foo@bar.com"
// ),
// [1] => array(
// "user_name" => "cat",
// "email" => "cat@dog.com"
// )
// )
foreach ( $datas as $data ) {
echo "user_name:" . $data ["user_name"] . " - email:" . $data ["email"] . "
";
}
// Select all columns
$datas = $database->select ( "account", "*" );
// Select a column
$datas = $database->select ( "account", "user_name" );
// $datas = array(
// [0] => "foo",
// [1] => "cat"
// )

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Zend Studio 13.0.1
Powerful PHP integrated development environment

Notepad++7.3.1
Easy-to-use and free code editor

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.