尝试使用Doctrine Query Builder查询数据库(它用于Symfony2表单,因此必须使用查询构建器)。
获得以下错误:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'c2_.caseFileID' in 'on clause'
我的查询如下:
$er->createQueryBuilder('ia')
->select( 'ia' )
->from( 'TheBundle:CaseInstruction', 'ci' )
->innerJoin( 'TheBundle:CaseFile', 'cf', 'WITH', 'ci.caseFile = cf' )
->innerJoin( 'TheBundle:Workflow', 'wf', 'WITH', 'wf.product = ci.product AND wf.company = cf.company' )
->innerJoin( 'TheBundle:WorkflowInstructionAction', 'wfia', 'WITH', 'wfia.instructionAction = ia AND wfia.workflow = wf' )
->innerJoin( 'TheBundle:Process', 'p', 'WITH', 'p.currentStatus = ci.status AND p.workflow = wf' )
->innerJoin( 'TheBundle:ProcessTrigger', 'pt', 'WITH', 'pt.instructionAction = ia AND pt.process = pt' )
->where( 'ci.id = :cid' )
->andWhere( 'ia.isSystemAction = :isSystemAction' )
->setParameter( 'isSystemAction', '0' )
->setParameter( 'cid', $options['caseInstructionId'] );
评估以下学说查询(如异常中所示):
'SELECT i0_.id AS id0,
i0_.codeName AS codeName1,
i0_.permissions AS permissions2,
i0_.description AS description3,
i0_.isSystemAction AS isSystemAction4,
i0_.instructionActivityID AS instructionActivityID5,
i0_.instructionSubjectID AS instructionSubjectID6
FROM InstructionAction i0_
INNER JOIN CaseFile c1_ ON (c2_.caseFileID = c1_.id)
INNER JOIN Workflow w3_ ON (w3_.productID = c2_.productID AND w3_.companyID = c1_.companyID)
INNER JOIN WorkflowInstructionAction w4_ ON (w4_.instructionActionID = i0_.id AND w4_.workflowID = w3_.id)
INNER JOIN Process p5_ ON (p5_.currentStatusID = c2_.instructionStatusID AND p5_.workflowID = w3_.id)
INNER JOIN ProcessTrigger p6_ ON (p6_.instructionActionID = i0_.id AND p6_.processID = p6_.id), CaseInstruction c2_
WHERE c2_.id = ?
AND i0_.isSystemAction = ?' with params ["307", "0"]
(试图使其尽可能可读)
有人知道如何修复此错误吗?我有本机SQL版本,我真的只是想把它翻译成Doctrine查询生成器。
编辑:正在运行的SQL:
SELECT ia.* FROM (InstructionAction ia, CaseInstruction ci)
JOIN CaseFile cf ON ci.caseFileID=cf.id
JOIN Workflow wf ON ci.productID=wf.productID AND wf.companyID = cf.companyID
JOIN WorkflowInstructionAction wia ON wia.workflowID=wf.id AND wia.instructionActionID = ia.id
JOIN Process p ON p.currentStatusID = ci.instructionStatusID AND p.workflowID = wf.id
JOIN ProcessTrigger pt ON pt.instructionActionID = ia.id AND pt.processID = p.id
WHERE ci.id = 275
AND ia.isSystemAction=0;
CaseInstruction ID 275
只是一个示例CaseInstruction ID - 在查询生成器中被$options['caseInstructionID']
取代。