I'm working on a server that uses doctrine orm, and i came across the following function:
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;
}
I would like to know what the colon on ':user' does at:
->leftJoin("eds.user", 'us', 'WITH', 'u = :user OR us = :user')
Thanks in advance.
The colon is used in parameter binding... you define a name: :user
And then you assign a value to that parameter in:
->setParameter('user', $this->getSession() )