Accoring to the Symfony 2 Documentation, you have to use the following PHP code to connect to the database and execute a query...
$conn = $this->get('database_connection');
$users = $conn->fetchAll('SELECT * FROM users');
I'm a complete novice with Symfony 2 but I am experienced with OOP. I was wondering if it was possible to have a globally available $conn
variable that I can access from any bundle. The $conn
variable would contain the value of $this->get('database_connection')
so I don't have to retype $conn = $this->get('database_connection');
it every time I want to make a new query.
Thanks!