Symfony 2 Errors and their meanings

Invalid parameter: token tokenName is not defined in the query.

Check your ->setParameter() statements to make sure your tokens (or first part of the setParameter statement) matches the :tokenName you used in your createQuery.

An example:

        $query = $this->getEntityManager()
                        MyBigBundle:Cat c
                        c.petName = :petName
                ->setParameter( 'peName' , $petName)

That would throw the error:

Invalid parameter: token peName is not defined in the query.

Because of the typo in the setParameter statement, it should be petName, but I put peName.

It sounds like it should be easy to spot, but when you have a few parameters, or you have been coding for several hours in a row, sometimes it’s easy to miss.

Be Sociable, Share!

Leave a Reply

Your email address will not be published. Required fields are marked *

This blog is kept spam free by WP-SpamFree.