Medoo Introduction
Medoo is a lightweight PHP SQL database framework developed by the founder Li Yan of the social networking site Catfan and the Open-source project Qatrix. Provides a simple, easy to learn, flexible API to enhance the efficiency and performance of Web application development, and the volume is only 8KB.
Characteristics
Lightweight, only one file
Simple and easy to learn, data structure at a glance
supports a variety of SQL syntax and supports complex query conditions
supports a variety of databases, including MySQL, MSSQL, SQLite, etc.
Security to prevent SQL injection
Free, based on the MIT Protocol
Sample code
Increase
Copy Code code as follows:
$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"
]
] );
Delete
Copy Code code as follows:
$database = new Medoo ("My_database");
$database->delete ("Account", [
"and" => [
"Type" => "Business"
"AGE[<]" => 18
]
]);
Modify
Copy Code code as follows:
$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
] );
Inquire
Copy Code code as follows:
$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"]. "<br>";
}
Select All Columns
$datas = $database->select ("Account", "*");
Select a column
$datas = $database->select ("account", "user_name");
$datas = Array (
[0] => "foo",
[1] => "Cat"
// )