[BUG] No results when adding more than 2 parameters to the querybuilder #5243

Open
opened 2026-01-22 15:02:27 +01:00 by admin · 1 comment
Owner

Originally created by @chris-code-lab on GitHub (Sep 9, 2016).

Package version

laravel-doctrine/orm v1.2.5
using -> doctrine/orm v2.5.4
Lumen v5.2.7.
Oracle database.

$conn = $this->getEntityManager()->getConnection();
$queryBuilder = $conn->createQueryBuilder();
$queryBuilder->select('*')
    ->from('SYNCHS')
    ->where('SYNCHS.CLIENT_ID = :clientId')
    ->andWhere('SYNCHS.TOP_CLIENT_ID = :topClientId')
    ->andWhere('SYNCHS.ID = :synchId');

$queryBuilder->setParameter('clientId', $clientId)
    ->setParameter('topClientId', $topClientId)
    ->setParameter('synchId', $synchId);

echo $queryBuilder->getSQL();
var_dump($queryBuilder->getParameters());

$stmt = $queryBuilder->execute();
var_dump($stmt);

$results = $stmt->fetchAll();
dd($results);

If I comment any one of the where/addwhere clause, I end up with the expected result set, but if I have more than 2 parameters bound, it returns an empty array instead of 1 row.
$queryBuilder->getParameters() is returning all 3 parameters.
When using the 3 parameters, if I copy / paste the string returned by $queryBuilder->getSQL(); into Toad and run the query against the database with the parameter values returned by $queryBuilder->getParameters(), I get 1 row.

Same thing happens when I use the setParameters() function instead of setParameter().

Expected behaviour

$results contains 1 row.

Actual behaviour

$results is an empty array.

Link of the issue opened in doctrine-laravel/orm github: https://github.com/laravel-doctrine/orm/issues/179

Originally created by @chris-code-lab on GitHub (Sep 9, 2016). ### Package version laravel-doctrine/orm v1.2.5 using -> doctrine/orm v2.5.4 Lumen v5.2.7. Oracle database. ``` $conn = $this->getEntityManager()->getConnection(); $queryBuilder = $conn->createQueryBuilder(); $queryBuilder->select('*') ->from('SYNCHS') ->where('SYNCHS.CLIENT_ID = :clientId') ->andWhere('SYNCHS.TOP_CLIENT_ID = :topClientId') ->andWhere('SYNCHS.ID = :synchId'); $queryBuilder->setParameter('clientId', $clientId) ->setParameter('topClientId', $topClientId) ->setParameter('synchId', $synchId); echo $queryBuilder->getSQL(); var_dump($queryBuilder->getParameters()); $stmt = $queryBuilder->execute(); var_dump($stmt); $results = $stmt->fetchAll(); dd($results); ``` If I comment any one of the where/addwhere clause, I end up with the expected result set, but if I have more than 2 parameters bound, it returns an empty array instead of 1 row. `$queryBuilder->getParameters()` is returning all 3 parameters. When using the 3 parameters, if I copy / paste the string returned by `$queryBuilder->getSQL();` into Toad and run the query against the database with the parameter values returned by `$queryBuilder->getParameters()`, I get 1 row. Same thing happens when I use the setParameters() function instead of setParameter(). ### Expected behaviour $results contains 1 row. ### Actual behaviour $results is an empty array. Link of the issue opened in doctrine-laravel/orm github: https://github.com/laravel-doctrine/orm/issues/179
Author
Owner

@Ocramius commented on GitHub (Sep 10, 2016):

This seems to be a DBAL issue. Do you have a reproducible test case for it?

@Ocramius commented on GitHub (Sep 10, 2016): This seems to be a DBAL issue. Do you have a reproducible test case for it?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5243