Get Started

Where Syntax




PDO object



version: 1.1.3

Get Started

Using Medoo is extremely easy!



On PHP 5.4+, you can use [] as short array syntax. All Medoo example code are using [] instead of array().

// On PHP 5.1
$data = array("foo", "bar");

// On PHP 5.4+
$data = ["foo", "bar"];

php_pdo extension list

PHP PDO driver installation

Medoo is requiring PHP with PDO supported. If you didn't install before, follow this step.

// Open php.ini and remove the ';' for the database extension you want to install.

// From

// To

// Save it, and restart PHP or Apache server.

// If PDO is installed successfully, you can find it on phpinfo().

Or install via terminal. The PDO_XXX extension will be enabled and configured automatically.

$ sudo apt-get install php5-mysql

Composer Installation

If you know about composer, it is easy to install and manage the version dependence. Just use this command to add Medoo to composer.json. Or you can edit it depend on your requirement.

$ composer require catfan/Medoo

And update the composer

$ composer update

Download Installation

The most simple way. Just download medoo.php and put it into the right directory and then require, and now you are ready!

require  'medoo.php';


There are three ways to configure medoo and start a database connection.

// If you installed via composer, just use this code to requrie autoloader on the top of your projects.
require 'vendor/autoload.php';

// Or if you just download the medoo.php into directory, require it with the correct path.
require  'medoo.php';

$database = new medoo([
	// required
	'database_type' => 'mysql',
	'database_name' => 'name',
	'server' => 'localhost',
	'username' => 'your_username',
	'password' => 'your_password',
	'charset' => 'utf8',

	// [optional]
	'port' => 3306,

	// [optional] Table prefix
	'prefix' => 'PREFIX_',

	// [optional] driver_option for connection, read more from
	'option' => [

$database->insert("account", [
	"user_name" => "foo",
	"email" => ""


If you want to use MSSQL with Medoo under PHP platform, you need to install pdo_sqlsrv PHP extension for Windows or pdo_dblib for Linux/UNIX. pdo_mssql extension is deprecated and will be removed from PHP.

For SQLite

$database = new medoo([
	'database_type' => 'sqlite',
	'database_file' => 'my/database/path/database.db'

$database->insert("account", [
	"user_name" => "foo",
	"email" => ""