I'm currently playing around with symfony and DBAL to collect data from an external database.
$conn = $this->get('database_connection');
$users = $conn->fetchAll('SELECT * FROM cms_clients');
print_r($users);
The code above works fine, but I need to do more complicated queries, and the only documentation I can find is http://doctrine-dbal.readthedocs.org/en/latest/reference/query-builder.html
The documentation is really good but i'm not sure how i would implement the code bellow in my example.
$queryBuilder
->select('u.id', 'u.name')
->from('users', 'u')
->where('u.email = ?')
->setParameter(0, $userInputEmail)
;
Solution, thanks for replays anyway
$conn = $this->get('database_connection');
$parms = array($DataSource, 'STORE');
$query = "SELECT * FROM cms_things LEFT JOIN cms_stores ON cms_things.id=cms_stores.thing_id WHERE client_id = ? AND type = ? ";
$users = $conn->fetchAll($query, $parms);