Skip to content
This repository has been archived by the owner. It is now read-only.
Pimple service provider for FluentPDO
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

FluentPDO Service Provider

Pimple service provider for FluentPDO.


Install provider through Composer:

composer require alexantr/fluentpdo-service-provider "~1.0@dev"

Registering and configuration

$app->register(new \Alexantr\Pimple\Provider\FluentPdoServiceProvider(), array(
    'fpdo.pdo_options' => array(
        'dsn' => 'mysql:dbname=blog;host=localhost;charset=UTF8',
        'username' => 'username',
        'password' => 'password',
    'fpdo.debug' => false,

Usage example

To get first ten records for table "posts":

$posts = $app['fpdo']
    ->where('published_at > ?', $date)
    ->orderBy('published_at DESC')

For more examples see FluentPDO documentation.

Enable debugging

Log queries to STDERR (for console debugging):

$app['fpdo.debug'] = true;

or set callback:

$app['fpdo.debug'] = $app->protect(function (\BaseQuery $query) use ($app) {
    // simple example with logger
    if (isset($app['logger']) && $app['logger'] !== null) {
        $debug_line = array();
        $debug_line[] = 'Query: ' . $q->getQuery(false);
        $debug_line[] = 'Params: ' . implode(', ', $q->getParameters());
        $debug_line[] = 'RowCount: ' . ($q->getResult() ? $q->getResult()->rowCount() : 0);
        $debug_line[] = 'Time: ' . $q->getTime();
        $app['logger']->debug(implode(', ', $debug_line));
You can’t perform that action at this time.