2017 © Pedro Peláez
 

library fluentpdo-service-provider

Pimple service provider for FluentPDO

image

alexantr/fluentpdo-service-provider

Pimple service provider for FluentPDO

  • Wednesday, August 10, 2016
  • by alexantr
  • Repository
  • 1 Watchers
  • 1 Stars
  • 32 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

FluentPDO Service Provider

Pimple service provider for FluentPDO., (*1)

Installation

Install provider through Composer:, (*2)

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":, (*3)

$posts = $app['fpdo']
    ->from('article')
    ->where('published_at > ?', $date)
    ->orderBy('published_at DESC')
    ->limit(5);

For more examples see FluentPDO documentation., (*4)

Enable debugging

Log queries to STDERR (for console debugging):, (*5)

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

or set callback:, (*6)

$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));
    }
});

The Versions

10/08 2016

dev-master

9999999-dev https://github.com/alexantr/fluentpdo-service-provider

Pimple service provider for FluentPDO

  Sources   Download

MIT

The Requires

 

service provider pimple fluentpdo