2017-08-02 88 views
1

什么是DQL findBy()查询语法? ();} getDoctrine() - > getRepository(“AppBundle:Users”) - > findBy($ queryWhere);DQL findBy默认查询

回答

0

这通常与实体的属性一起使用。它使用一个数组作为实体的属性名称和值作为您要搜索的值。

例子:

$this->getDoctrine() 
    ->getRepository('AppBundle:Users') 
    ->findBy(['id' => $id]) 
; 

$this->getDoctrine() 
    ->getRepository('AppBundle:Users') 
    ->findBy(['userName' => $userName]) 
; 

$this->getDoctrine() 
    ->getRepository('AppBundle:Users') 
    ->findBy(['email' => $email]) 
; 

你可以阅读更多关于它在这里:https://symfony.com/doc/current/doctrine.html#fetching-objects-from-the-database

+0

Tnx但我想知道什么是dql语法像'select u from ...' –