jworksuk / extra-pdo
There is no license information available for the latest version (v0.1) of this package.
v0.1
2018-04-10 20:15 UTC
Requires (Dev)
- codedungeon/phpunit-result-printer: 0.8.2
- phpunit/phpunit: ^6.5
- squizlabs/php_codesniffer: ^3.2
- symfony/var-dumper: ^3.4
This package is not auto-updated.
Last update: 2025-04-10 03:45:49 UTC
README
A very thin layer over the PDO class.
Install
Via Composer
$ composer require jworksuk/extra-pdo
Usage
require_once '/path/to/vendor/autoload.php'; use JWorksUK\ExtraPDO; use Acme\Model; $pdo = ExtraPDO::createMySqlConnection( 'databaseName', 'databaseHost', 'databaseUser', 'databasePassword' ); $model = $pdo ->executeStatement('SELECT * FROM todos WHERE id=:id', [ 'id' => '15983acf-022f-303a-bfef-a096eaebbf7c' ]) ->fetchAndMap(function ($row) { return new Model( $row['id'], $row['name'], $row['list_id'], new \DateTime($row['updated_at']), new \DateTime($row['created_at']) ); }); $model->doModelThing(); $models = $pdo ->executeStatement('SELECT * FROM todos WHERE list_id=:listId', [ 'listId' => '05aab6f6-e991-3c59-a980-832cca75c578' ]) ->fetchAllAndMap(function ($row) { return new Model( $row['id'], $row['name'], $row['list_id'], new \DateTime($row['updated_at']), new \DateTime($row['created_at']) ); }); foreach ($models as $model) { $model->doModelThing(); }
Testing
$ composer test