I'm trying to create a Doctrine DBAL querybuilder object and setting a parameter in it. (using a postgres db, dbal 2.3.4, doctrine
$connection = $this->_em->getConnection();
$qb = $connection->createQueryBuilder();
$qb->select('tbl_user_contract.pkid AS pkid');
$qb->from('tbl_user_contract', 'tbl_user_contract');
$qb->join('tbl_user_contract', 'tbl_user', 'tbl_user', 'tbl_user_contract.fk_user = tbl_user.pkid');
$qb->where('tbl_user.pkid = :userid');
$qb->setParameter(':userid', 10);
When I try to get the results of this querybuilder object I get the following error:
SQLSTATE[08P01]: <<Unknown error>>: 7 ERROR: bind message supplies 0 parameters,
but prepared statement "pdo_stmt_00000002" requires 1
When I check the postgres logs, I see the query passing by and I notice that it expects a parameter, but I won't get a parameter passed in.
I tried to set the id in the where expression itself (without using prepared statements), that worked. But I really want to get this working with prepared statements.
Anyone knows how to solve this?
Thanks in advance