Last active
October 24, 2017 21:50
-
-
Save adrianpietka/75e17203e16eae8a6e62986b26e8e3d3 to your computer and use it in GitHub Desktop.
Silex + Doctrine DBAL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // .. | |
| $app->register(new Silex\Provider\DoctrineServiceProvider(), [ | |
| 'db.options' => [ | |
| 'driver' => 'pdo_mysql', | |
| 'host' => 'localhost', | |
| 'port' => 3306, | |
| 'dbname' => 'database_name', | |
| 'user' => 'root', | |
| 'password' => 'password' | |
| ] | |
| ]); | |
| // .. | |
| $params = [':authorId' => 1]; | |
| $sql = 'SELECT * FROM articles WHERE author_id = :authorId'; | |
| return $app['db']->fetchAll($sql, $params); | |
| // .. composer.json | |
| /* | |
| { | |
| "require": { | |
| "silex/silex": "2.2.*", | |
| "doctrine/dbal": "2.6.*" | |
| } | |
| } | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment