Skip to content
This repository has been archived by the owner on Sep 17, 2020. It is now read-only.

ancarda/pdoplus

Repository files navigation

ancarda/pdoplus

PDO with some extra niceties

Latest Stable Version Total Downloads License Build Status Coverage Status

To install, simply run

composer require ancarda/pdo-plus

Usage

Wrap an existing PDO object like so:

$pdo     = new PDO(...);
$pdoPlus = new PDOPlus($pdo);

PDO Plus will set two attributes on your connection:

  • Use FETCH_ASSOC to return associative arrays.
  • Use ERRMODE_EXCEPTION to throw PDOException from methods.

From there, you can use the query method which takes the SQL query as the first parameter and the prepared statement params as the second parameter. Query returns multiple rowsets for use with SQL Server and MySQL.

For everything else, you can use getPDO.

Transactions

For an RAII style of transactions, you can call createTransaction.

For a more functional approach, use tryTransaction which wraps the transaction in a closure.

Releases

No releases published

Packages

No packages published

Languages