MySQL说参数没有定义,但确实如此

时间:2017-08-10 13:02:25

标签: mysql symfony doctrine

我多次检查过我的请求而且我不明白为什么MySQL会显示此错误(SQLSTATE [HY093]:参数号无效:参数未定义):

public function getOneBySlug($slug)
{
    $query = $this
        ->createQueryBuilder('c')
        ->select('partial c.{id, slug, name, description, imagePath, imageExt}')
        ->where('c.slug = :slug')
        ->setParameter('slug', $slug)
        ->getQuery()
        ->useResultCache(true, 300)
        ->getOneOrNullResult()
    ;

    return $query;
}

真正的要求:

SELECT c0_.id AS id_0
     , c0_.slug AS slug_1
     , c0_.name AS name_2
     , c0_.description AS description_3
     , c0_.image_path AS image_path_4
     , c0_.image_ext AS image_ext_5
     , c0_.parent_id AS parent_id_6
FROM category_store c0_
WHERE c0_.slug = 'thing';

如您所见,只有一个参数。

感谢您的帮助。

0 个答案:

没有答案