':'(冒号)在dql中是什么意思?

时间:2019-07-23 20:44:14

标签: php doctrine-orm dql

我正在使用主义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')

谢谢。

1 个答案:

答案 0 :(得分:2)

冒号用于参数绑定...您定义一个名称::user

然后在以下位置为该参数分配一个值:

->setParameter('user', $this->getSession() )