':'(冒号)在dql中是什么意思?
What does ':'(colon) mean in dql?
我在使用 doctrine orm 的服务器上工作,我遇到了以下函数:
public function showForJustWhoCanSee() {
$subquery = $this->em->createQueryBuilder();
$subquery->select('userSignature')
->from('HospitalApi\Entity\EletronicDocumentSignature', 'signature')
->innerJoin('HospitalApi\Entity\User', 'userSignature', 'WITH', 'userSignature = signature.user')
//->where('signature.signed = 0')
->groupBy('signature._document')
->orderBy('signature.order', 'ASC');
$select = $this->em->createQueryBuilder();
$select->select('ed')
->from($this->getEntityPath(), 'ed')
->innerJoin("HospitalApi\Entity\User", "u", "with", "ed.user = u")
->leftJoin("HospitalApi\Entity\EletronicDocumentSignature", 'eds', 'WITH', 'eds._document = ed')
->leftJoin("eds.user", 'us', 'WITH', 'u = :user OR us = :user')
->where( $select->expr()->eq( 'us', $select->expr()->any( $subquery->getDQL() )) )
// ->andwhere('eds.signed = 0')
// ->andwhere( $select->expr()->in('ed.status', $this->_alowedStatusToSign) )
->orwhere('u = :user')
->setParameter('user', $this->getSession() )
->andWhere('ed.c_removed = 0');
return $select;
}
我想知道“:user”上的冒号在以下位置的作用:
->leftJoin("eds.user", 'us', 'WITH', 'u = :user OR us = :user')
提前致谢。
冒号用于参数绑定...您定义一个名称::user
然后您为该参数赋值:
->setParameter('user', $this->getSession() )
我在使用 doctrine orm 的服务器上工作,我遇到了以下函数:
public function showForJustWhoCanSee() {
$subquery = $this->em->createQueryBuilder();
$subquery->select('userSignature')
->from('HospitalApi\Entity\EletronicDocumentSignature', 'signature')
->innerJoin('HospitalApi\Entity\User', 'userSignature', 'WITH', 'userSignature = signature.user')
//->where('signature.signed = 0')
->groupBy('signature._document')
->orderBy('signature.order', 'ASC');
$select = $this->em->createQueryBuilder();
$select->select('ed')
->from($this->getEntityPath(), 'ed')
->innerJoin("HospitalApi\Entity\User", "u", "with", "ed.user = u")
->leftJoin("HospitalApi\Entity\EletronicDocumentSignature", 'eds', 'WITH', 'eds._document = ed')
->leftJoin("eds.user", 'us', 'WITH', 'u = :user OR us = :user')
->where( $select->expr()->eq( 'us', $select->expr()->any( $subquery->getDQL() )) )
// ->andwhere('eds.signed = 0')
// ->andwhere( $select->expr()->in('ed.status', $this->_alowedStatusToSign) )
->orwhere('u = :user')
->setParameter('user', $this->getSession() )
->andWhere('ed.c_removed = 0');
return $select;
}
我想知道“:user”上的冒号在以下位置的作用:
->leftJoin("eds.user", 'us', 'WITH', 'u = :user OR us = :user')
提前致谢。
冒号用于参数绑定...您定义一个名称::user
然后您为该参数赋值:
->setParameter('user', $this->getSession() )