dibi


Excelent database abstraction layer

Dibi is tiny 'n' smart database abstraction layer for PHP 5.

http://dibiphp.com/images/logo-white.gif

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

Code samples

``` // connect to database dibi::connect(array( 'driver' => 'mysql', 'host' => 'localhost', 'username' => 'root', 'password' => '*', ));

// select, insert, update dibi::query('SELECT * FROM [table] WHERE [id] = %i', $id);

$arr = array( 'name' => 'John', 'is_admin' => TRUE, ); dibi::query('INSERT INTO [table]', $arr); // INSERT INTO table (name, is_admin) VALUES ('John', 1)

dibi::query('UPDATE table SET ', $arr, 'WHERE id=%i', $x); // UPDATE table SET name='John', is_admin=1 WHERE id = 123

// getting results $result = dibi::query('SELECT * FROM table');

$value = $result->fetchSingle(); // single value $all = $result->fetchAll(); // all rows $assoc = $result->fetchAssoc('id'); // all rows as associative array $pairs = $result->fetchPairs('customerID', 'name'); // all rows as key => value pairs

// iterating foreach ($result as $n => $row) { print_r($row); } ```

See more examples.

Project Information

Labels:
PHP mysql odbc database mysqli pdo mssql sqlite postgresql adodb orm