Medoo: An Ideal Database Framework for Efficient Web Development

December 29, 2014

Medoo is a light-weighted non-MVC framework that acts as an efficient medium to connect database to PHP. The framework was developed by Angel Lai, a profound designer and entrepreneur. Medoo is literally build using PHP and is compatible with MySQL, PostgreSQL, MSSQL, SQLite etc. It provides the facility to extend the existing functionality.

Installation
  • ·Download Medoo
  • ·There is only one file and you can configure it
protected $database_type = 'mysql';

protected $server = 'hostname';

protected $database_type = 'mysql';

protected $username = 'username';

protected $password = 'password';
Using Medoo in your projects

1.   Include medoo in your project

require_once 'medoo.php';

2.  Initialization

 $database = new medoo('database');
Coding

info() :

returns functions of database

Insertion :

$database->insert ('student', [

'user_name' => 'abc'

'email' => ‘[email protected]',

'age' => 25,

]);

Inserting values into the table student

Select :

$datas = $database->select ("student", [

"user_name",

"email"

], ["user_id[>]" => 100

]);

foreach($datas as $data)

{

echo "user_name:" . $data["user_name"] . “- email:”. $data["email"] . "<br/>";

}

select user_name , email , user_id from table student with user_id > 100
and display the data using for loop

Update :

$database->update(“student”,[“email”=>”[email protected]”],[“user_id”=>”2”]);

update the table row student with email is  [email protected] and user_id is 2

Delete :

$database->delete(“student”,[“AND”=>[“user_id”=>”3”]]);

delete the row from the table student with user_id is 3

Aggregate functions:

count/min/max/avg/sum

Given below is an example of aggregate function for finding minimum age.

$database->min(“student”, “age”,[“age[<]”=>”20”]);

returns the min of age from the table student with age less than 20.

Replace:

replace the old data into new one.

$database->replace("student", ["type" => [ "user" => "new_user"],"group" => ["groupA" => "groupB"]], ["user_id[>]" => 1000]);

Medoo is simple and handy; it has method for all the SQL queries. It does not cause any revolutionary change but for free MIT license, you can use it anywhere you want. I’m definitely planning to write more about Medoo, i would love to hear your opinions about this post, therefore, don’t hesitate to drop a comment.

Know More About This Topic from our Techies

What Are You Missing in Your Web Application Project and Why Do We Recommend Laravel
Why Laravel Application Development Is Not a Piece of Cake for Everyone
Why Are Web Applications Necessary for Emerging Businesses?
Creating animations in Flutter by using Rive
Flutter's Animation Support
Motion UI SaaS Library for Creating Flexible UI And Transitions

Latest Post

Get a free quote