Skip to content

Connection factory

Presentation

You can use connection factory to get connection to database.

This is useful to make raw sql queries for example.

Execute a sql query

use Small\SwooleEntityManagerBundle\Contract\ConnectionFactoryInterface;

$resultset = $container->get(ConnectionFactoryInterface::class)
    ->get('sso_users')
    ->execute('select * from users')
;

You can skip the connection parameter to use default connection :

use Small\SwooleEntityManagerBundle\Contract\ConnectionFactoryInterface;

$resultset = $container->get(ConnectionFactoryInterface::class)
    ->get()
    ->execute('select sum(total_amount) as total_sales from invoices')
;