protected function buildAssociationQuery($qb, $assoc, $alias, $params)
    {
        $data = $this->em->getClassMetadata($assoc);
        foreach ($params as $key => $val) {
            if (isset($data->associationMappings)) {
                if ($map = array_key_exists($key, $data->associationMappings)) {
                    if (is_array($val)) {
                        $qb->innerJoin("$alias.$key", "_$key");
                        foreach ($val as $column => $v) {
                            if (is_array($v)) {
                                $this->buildAssociationQuery($qb, $map['targetEntity'], $column, $v);
                                continue;
                            }
                            $paramname = "_$key" . '__' . $column;
                            $qb->andWhere("_$key.$column = :$paramname");
                            $qb->setParameter($paramname, $v);
                        }
                        continue;
                    }
                }
            }
            if ($val === null) {
                $qb->andWhere("s.$key IS NULL");
            } else {
                $paramname = str_replace(".", "", "s_$key");
                $qb->andWhere("s.$key = :$paramname");
                $qb->setParameter($paramname, $val);
            }
        }
    }
protected function buildAssociationQuery($qb, $assoc, $alias, $params)
    {
        $data = $this->em->getClassMetadata($assoc);
        foreach ($params as $key => $val) {
            if (isset($data->associationMappings)) {
                if ($map = array_key_exists($key, $data->associationMappings)) {
                    if (is_array($val)) {
                        $qb->innerJoin("$alias.$key", "_$key");
                        foreach ($val as $column => $v) {
                            if (is_array($v)) {
                                $this->buildAssociationQuery($qb, $map['targetEntity'], $column, $v);
                                continue;
                            }
                            $paramname = "_$key" . '__' . $column;
                            $qb->andWhere("_$key.$column = :$paramname");
                            $qb->setParameter($paramname, $v);
                        }
                        continue;
                    }
                }
            }
            if ($val === null) {
                $qb->andWhere("s.$key IS NULL");
            } else {
                $paramname = str_replace(".", "", "s_$key");
                $qb->andWhere("s.$key = :$paramname");
                $qb->setParameter($paramname, $val);
            }
        }
    }
protected function buildAssociationQuery ( $ qb , $ assoc , $ alias , $ params ) { $ data = $ this -> em -> getClassMetadata ( $ assoc ) ; foreach ( $ params as $ key => $ val ) { if ( isset ( $ data -> associationMappings ) ) { if ( $ map = array_key_exists ( $ key , $ data -> associationMappings ) ) { if ( is_array ( $ val ) ) { $ qb -> innerJoin ( "$alias.$key" , "_$key" ) ; foreach ( $ val as $ column => $ v ) { if ( is_array ( $ v ) ) { $ this -> buildAssociationQuery ( $ qb , $ map [ 'targetEntity' ] , $ column , $ v ) ; continue ; } $ paramname = "_$key" . '__' . $ column ; $ qb -> andWhere ( "_$key.$column = :$paramname" ) ; $ qb -> setParameter ( $ paramname , $ v ) ; } continue ; } } } if ( $ val === null ) { $ qb -> andWhere ( "s.$key IS NULL" ) ; } else { $ paramname = str_replace ( "." , "" , "s_$key" ) ; $ qb -> andWhere ( "s.$key = :$paramname" ) ; $ qb -> setParameter ( $ paramname , $ val ) ; } } }
It's Fuckin Recursive!

@param $qb
@param $assoc
@param $alias
@param $params
It s Fuckin Recursive!