arabcoders / db
Extends PDO to add extra methods.
1.6.0
2019-02-25 12:40 UTC
Requires
- php: >=7.2
- ext-mbstring: *
- ext-pdo: *
Requires (Dev)
- phpunit/phpunit: ^5.0
README
This package extends PDO to implement extra method to ease the use of prepared statements, and add shortcut methods for update/delete/insert/select.
Install
Via Composer
$ composer require arabcoders/db
Usage Example.
<?php require __DIR__ . '/../../autoload.php'; $pdo = new PDO( 'mysql:host=localhost;dbname=dbName', 'dbUser', 'dbPassword' ); $db = new \arabcoders\db\Db( $pdo ); $insert = $db->insert( 'tableName',[ 'id' => 1, 'name' => 'foo' ]); //-- get last insert id. $id = $db->id(); // -- update row. $update = $db->update( 'tableName', [ 'name' => 'bar' ],[ 'id' => $id ] ); $delete = $db->delete( 'tableName', [ 'id' => $id ]);