Skip to content


DDC-3034: QueryBuilder invalid number of bound params #3803

doctrinebot opened this Issue · 4 comments

2 participants


Jira issue originally created by user michalz:

     * @param int  $companyId
     * @param bool $includeDeleted
     * @return \Doctrine\ORM\QueryBuilder
    public function findCompanySubjects($companyId, $includeDeleted = false)
            ->innerJoin('t.owner', 'owner')
            ->innerJoin('', 'company')
            ->andWhere('t.deleted = :deleted')
            ->andWhere(' = :id')
            ->orderBy('', 'asc')

            ->setParameter('deleted', $includeDeleted)
            ->setParameter('id', $companyId)

        return $qb;

Code above does not work for me. I'm still getting an error "Invalid parameter number: number of bound variables does not match number of tokens". However, bound parameters does work with raw DQL and the Query object.


Comment created by @ocramius:

[~michalz] what is the complete DQL that is produced for that query? And does it work with a DQL query written directly (rather than the QB)?


Comment created by michalz:

Raw DQL is:

SELECT t, owner FROM Domain\Entity\Subject t INNER JOIN t.owner owner INNER JOIN company WHERE t.deleted = :deleted AND = :id ORDER BY asc

And yes, it does work with a DQL query written directly:

        // $qb from above

            'deleted' => $includeDeleted,
            'id'      => $companyId

        debug($query->getArrayResult()); // returns a list of subjects

Comment created by @ocramius:

You are returning the QB in your reported code - I'm pretty sure that some interaction with it is going on at a later point in time.

Could you provide the code that is causing the problem? Otherwise, this doesn't look like a bug to me.


Issue was closed with resolution "Invalid"

@Ocramius Ocramius was assigned by doctrinebot
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.