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

doctrinebot opened this Issue Mar 17, 2014 · 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('owner.company', 'company')
            ->andWhere('t.deleted = :deleted')
            ->andWhere('company.id = :id')
            ->orderBy('t.name', '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 owner.company company WHERE t.deleted = :deleted AND company.id = :id ORDER BY t.name 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 Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment