alexantr/fluentpdo-service-provider
Composer 安装命令:
composer require alexantr/fluentpdo-service-provider
包简介
Pimple service provider for FluentPDO
README 文档
README
Pimple service provider for FluentPDO.
Installation
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'] ->from('article') ->where('published_at > ?', $date) ->orderBy('published_at DESC') ->limit(5);
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)); } });
统计信息
- 总下载量: 40
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-04-20