Q:

createQueryBuilder()->where() issue. bound variables and tokens do not match

I'm having an issue with doctrine2 and symfony2. I am trying to create a Group repository and I continue to get this error:
Invalid parameter number: number of bound variables does not match number of tokens 
I've looked at the doctrine2 syntax to figure out why my createQueryBuilder object was giving me trouble with my where() helper function and it seems like I'm doing everything correctly. Bellow is my code:
<?php

namespace Blogger\BlogBundle\Entity\Repository;

use Doctrine\ORM\EntityRepository;

/**
 * GroupRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class GroupRepository extends EntityRepository
{
    public function getGroupByName($name)
    {
        return $this->createQueryBuilder('g')
            ->select('g')
            ->where('g.name=:' . $name)
            ->getQuery()
            ->getSingleResult();
    }
}

A:

binding your query parameters using setParameter() is the key to success here ... read more about it here.
public function getGroupByName($name)
{
    return $this->createQueryBuilder('g')
        ->where('g.name = :name')
        ->setParameter('name', $name)
        ->getQuery()
        ->getSingleResult();
}

