我正在尝试为我们的Web应用程序项目中的被拒绝的事务页面创建一个搜索字段,我使用symfony2框架,我被卡住了因为有错误说,
' [语义错误]第0行,第235行附近' b加入b.ediAk403ErrorCodes':错误:类Matrix \ MatrixEdiBundle \ Entity \ EdiTransaction没有名为edi997Details的关联'
以及
' CRITICAL - 未捕获的PHP异常Doctrine \ ORM \ Query \ QueryException:" [语义错误]第0行,第235行附近' b JOIN b.ediAk403ErrorCodes':错误:类Matrix \ MatrixEdiBundle \ Entity \ EdiTransaction没有名为edi997Details的关联" at /tmxpage/apache/htdocsEDI/Editracker/vendor/doctrine/orm/lib/Doctrine/ORM/Query/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;
}
这是我的实用代码,用于高级ediAk403ErrorCodes:
class EdiAk403ErrorCodes
{
/**
* @var string
*
* @ORM\Column(name="condition", type="string", length=50, nullable=false)
*/
private $condition;
/**
* @var integer
*
* @ORM\Column(name="error_code", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(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 \Matrix\MatrixEdiBundle\Entity\Edi997Details
*/
public function getEdi997Details()
{
return $this->edi997Details;
}
}
答案 0 :(得分:3)
似乎您的实体类EdiTransaction
与表EdiAk403ErrorCodes
没有明确的学说关系。因此,尝试在EdiTransaction类中添加具有正确注释的字段定义,如下所示:
EdiTransaction
/**
* @ORM\ManyToOne(targetEntity="Matrix\MatrixEdiBundle\Entity\Edi997Details", inversedBy="editTransactions")
* @ORM\JoinColumn(name="edit_details_id", referencedColumnName="id")
*/
private $edi997Details;
希望这个帮助
答案 1 :(得分:0)
单个字母用作表格的简称。在第一行中,您将MatrixEdiBundle:EdiTransaction与字母a相关联。所以a.edi997Details
只有在它是一个表的一列时才有意义。我相信你所需要的只是:
FROM MatrixEdiBundle:EdiTransaction a
JOIN edi997Details b
JOIN ediAk403ErrorCodes c