keiii / pdo-wrapper
Wrapper of PHP PDO class.
Installs: 2 236
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=5.5|^7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^1.0
- phpunit/dbunit: ^1.0|^2.0
- phpunit/phpunit: ^4.0|^5.0
This package is not auto-updated.
Last update: 2023-03-10 14:25:48 UTC
README
Provides wrapper of PHP PDO class to solve verbosity problem.
Installation
composer require keiii/pdo-wrapper
Example
<?php use KEIII\PdoWrapper\PdoWrapper; use KEIII\PdoWrapper\PdoQuery; $db = new PdoWrapper('sqlite::memory:'); // write $sql = 'INSERT INTO people (name) VALUES (:name);'; $parameters = [':name' => 'John']; $db->write(new PdoQuery($sql, $parameters)); // read one $sql = 'SELECT * FROM people WHERE name = :name;'; $parameters = [':name' => 'John']; $john = $db->read(new PdoQuery($sql, $parameters))->getFirst(); // as generator $sql = 'SELECT * FROM people;'; $people = $db->read(new PdoQuery($sql))->asGenerator(); foreach ($people as $human) { // ... }