arseniew / silex-idiorm-provider
Silex service provider for Idiorm
Installs: 2 320
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 3
Forks: 5
Open Issues: 0
Requires
- j4mie/idiorm: 1.4.*
This package is not auto-updated.
Last update: 2024-12-21 17:34:25 UTC
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();