我正试图在我们的web应用程序项目中为被拒绝的交易页面创建一个搜索字段,我使用的是symfony2框架,我被卡住了,因为有一个错误说,
"[语义错误]第0行,第235列,靠近"b JOIN b.ediAk403ErrorCodes":错误:Class Matrix \MatrixEdiBundle\Entity\EdiTransaction没有名为edi997Details的关联"
以及
'CRITICAL-未捕获的PHP异常Doctrine\ORM\QueryException:"[语义错误]行0,col 235靠近'b JOIN b.ediAk403ErrorCodes':错误:Class Matrix\MatrixEdiBundle\Entity\EdiTransaction没有名为edi997Details的关联",位于/txpage/apache/htdocsEDI/Editracker/vvendor/morine/ORM/lib/Doctrine/OM/QueryException.PHP行63'
这是我的代码(在我的存储库中):
public function getDetails($gsNumber, $senderId, $receiverId, $page = 1, $limit = 5 ){
$em = $this->getEntityManager();
$query = $em->createQuery(
'SELECT partial a.{ediTransactionId, senderId, receiverId, gsNumber, isaNumber, fileName },
partial b.{errorCodeId, noOfTrans},
partial c.{errorCode, condition}
FROM MatrixEdiBundle:EdiTransaction a
JOIN a.edi997Details b
JOIN b.ediAk403ErrorCodes c
WHERE b.errorCodeId != 1
AND a.flag = 1
AND a.gsNumber LIKE :gsNumber
AND a.senderId LIKE :senderId
AND a.recieverId LIKE :receiverId')
->setParameter('gsNumber', "%gsNumber%")
->setParameter('senderId', "%senderId%")
->setParameter('receiverId'ssss, "%receiverId%")
->setFirstResult(($page-1)*$limit)
->setMaxResults($limit);
$paginator = new Paginator($query, $fetchJoinCollection = false );
$paginator->setUseOutputWalkers(false);
return $paginator;
}
这是我的talble ediAk403ErrorCodes:的实体代码
class EdiAk403ErrorCodes
{
/**
* @var string
*
* @ORMColumn(name="condition", type="string", length=50, nullable=false)
*/
private $condition;
/**
* @var integer
*
* @ORMColumn(name="error_code", type="integer")
* @ORMId
* @ORMGeneratedValue(strategy="IDENTITY")
*/
private $errorCode;
/**
* Set condition
*
* @param string $condition
* @return EdiAk403ErrorCodes
*/
public function setCondition($condition)
{
$this->condition = $condition;
return $this;
}
/**
* Get condition
*
* @return string
*/
public function getCondition()
{
return $this->condition;
}
/**
* Get errorCode
*
* @return integer
*/
public function getErrorCode()
{
return $this->errorCode;
}
/**
* Get edi997Details
*
* @return MatrixMatrixEdiBundleEntityEdi997Details
*/
public function getEdi997Details()
{
return $this->edi997Details;
}
}
似乎您的实体类EdiTransaction
与表EdiAk403ErrorCodes
没有明确的条令关系。因此,尝试在EdiTransaction类中添加具有正确注释的字段定义,如下所示:
EdiTransaction
/**
* @ORMManyToOne(targetEntity="MatrixMatrixEdiBundleEntityEdi997Details", inversedBy="editTransactions")
* @ORMJoinColumn(name="edit_details_id", referencedColumnName="id")
*/
private $edi997Details;
希望这能帮助
单个字母用作表的短名称。在第一行中,您将MatrixEdiBundle:EdiTransaction和字母a相关联。所以a.edi997Details
只有在它是表的一列时才有意义。我相信你只需要这个:
FROM MatrixEdiBundle:EdiTransaction a
JOIN edi997Details b
JOIN ediAk403ErrorCodes c