PHP Lightweight database Operation class Medoo Add, delete, modify, query example _php tutorial

Source: Internet
Author: User
Medoo Introduction

Medoo is an ultra-lightweight PHP SQL database framework developed by Li Yan, founder of the social networking site Catfan and the Open source project Qatrix. Provides a simple, easy-to-learn, flexible API that improves the efficiency and performance of developing Web applications, and is less than 8KB in volume.

Characteristics

Lightweight, with only one file

Easy to learn, data structure at a glance

supports multiple SQL syntax and supports complex query conditions

Support multiple databases, including MySQL, MSSQL, SQLite, etc.

Security to prevent SQL injection

Free, based on the MIT Protocol

Sample code

Increase

Copy the 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 the Code code as follows:
$database = new Medoo ("My_database");

$database->delete ("Account", [
"and" = [
"Type" = "Business"
"AGE[<]" = 18
]
]);

Modify

Copy the 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 the 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"]. "
";
}

Select All Columns
$datas = $database->select ("Account", "*");

Select a column
$datas = $database->select ("account", "user_name");

$datas = Array (
[0] = "foo",
[1] = "Cat"
// )

http://www.bkjia.com/PHPjc/824650.html www.bkjia.com true http://www.bkjia.com/PHPjc/824650.html techarticle Medoo Introduction Medoo is an ultra-lightweight PHP SQL database framework developed by Li Yan, founder of the social networking site Catfan and open source project Qatrix. Provide a simple, easy to learn, flexible API, mention ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.