Skip to content

Latest commit

 

History

History
48 lines (36 loc) · 1.2 KB

@home.texy

File metadata and controls

48 lines (36 loc) · 1.2 KB
Dibi Is Database Abstraction Library ************************************ Dibi supports a lot of significant databases: MySQL, PostgreSQL, SQLite, MS SQL, Oracle, Access and generic PDO and ODBC. Code Samples ------------ ```php // 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]. {{maintitle: Dibi – Smart Database Abstraction Library for PHP}}