tiny 'n' smart
database layer

Dibi supports a lot of significant databases: MySQL, PostgreSQL, SQLite, MS SQL, Oracle, Access and generic PDO and ODBC.

Code Samples

// connect to database
$database = new Dibi\Connection([
    'driver'   => 'mysqli',
    'host'     => 'localhost',
    'username' => 'root',
    'password' => '***',
    'database' => 'table',
]);

// SELECT
$result = $database->query('SELECT * FROM users');

foreach ($result as $row) {
	echo $row->id;
	echo $row->name;
}

$value = $result->fetchSingle(); // returns the first cell
$all = $result->fetchAll(); // array of all rows
$assoc = $result->fetchAssoc('id'); // array of all rows, key is id
$pairs = $result->fetchPairs('id', 'name'); // returns the associative pairs id => name

// INSERT & UPDATE
$arr = [
    'name' => 'John',
    'is_admin'  => true,
];

$database->query('INSERT INTO users', $arr);
// INSERT INTO users (`name`, `is_admin`) VALUES ('John', 1)

$database->query('UPDATE users SET', $arr, 'WHERE id=?', $id);
// UPDATE users SET `name`='John', `is_admin`=1 WHERE id = 123

Read documentation.