arseniew/silex-idiorm-provider
最新稳定版本:v1.1.2
Composer 安装命令:
composer require arseniew/silex-idiorm-provider
包简介
Silex service provider for Idiorm
README 文档
README
Provider for integrating Idiorm with Silex
Registering and configuration
$app->register(new \Arseniew\Silex\Provider\IdiormServiceProvider(), array( 'idiorm.db.options' => array( 'connection_string' => 'mysql:host=localhost;dbname=my_db', 'username' => 'my_username', 'password' => 'my_password', ) );
For more details on configuration array see: Idiorm configuration options
Usage in controller
To get all records for given table:
$app['idiorm.db']->for_table('my_table')->findMany();
For more query examples see: Idiorm querying
Multiple connections
To configure multiple connections use $app['idiorm.dbs.options']
$app['idiorm.dbs.options'] = array( 'first_connection' => array( 'connection_string' => 'mysql:host=localhost;dbname=my_db', 'username' => 'my_username', 'password' => 'my_password', ), 'second_connection' => array( 'connection_string' => 'sqlite:./example.db' ) );
$app['idiorm.dbs.options'] Needs to be associative array, where keys will be connection names, and value will contain configuration array
To use connections in controller:
$app['idiorm.dbs']['first_connection']->for_table('my_table')->findMany(); $app['idiorm.dbs']['second_connection']->for_table('other_table')->findMany();
统计信息
- 总下载量: 2.56k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-12-08