条令查询错误未知列



我在Symfony3项目中使用Doctrine。我正在使用实体管理器从数据库中获取数据,但我有一个意外的错误,似乎是由条令生成的。

在呈现模板期间引发异常("执行SELECT t0.id AS id_1,t0.date AS date_2,t0.comment AS comment_3,t0.viewed AS viewed_4,t0.error_count AS error_count_5,t0.of_id AS of _id_6,t0.checkpoint_id AS checkpoint_id_7,t8.id AS id_9,t8.name AS name_10,t8.description AS description_11,t8.deleted_at AS deleted_at_12,t8.factory_id AS factory_id_13,t0.operator_id AS operateur_id_15,t0.factory时发生异常_id AS factory_id_16 FROM app_check_set t0 LEFT JOIN app_checkpoint t8 ON t0.checkpoint_id=t14.id AND((t14.deleted_at为NULL))其中t0.factory_id=?ORDER BY t0.date DESC LIMIT 5'with params[3]:

SQLSTATE[42S22]:未找到列:1054"on clause"中的未知列"t14.id")。

由于我不是自己创建查询,我想知道这个错误是从哪里来的?它与我的实体配置有关吗

问题是当我想获得我的实体Checkset:时

public function notificationsAction(Request $request){
$user           = $this->getUser();
$em             = $this->getDoctrine()->getManager();
return $this->render('AppBundle:Home:notifications.html.twig', array(
'notifications' => $em->getRepository('AppBundle:CheckSet')->findBy(array('factory' => $user->getFactory()->getId()), array('date' => 'desc'), 5),
'count'         => count($em->getRepository('AppBundle:CheckSet')->findBy(array('factory' => $user->getFactory()->getId(), 'viewed' => false)))
));
}

我的实体是这样的:

检查集:

<?php
namespace AppBundleEntity;
use DoctrineORMMapping as ORM;
use UserBundleEntityUser;
use DoctrineCommonCollectionsArrayCollection;
/**
* CheckSet
*
* @ORMTable(name="app_check_set")
* @ORMEntity(repositoryClass="AppBundleRepositoryCheckSetRepository")
*/
class CheckSet
{
/**
* @var int
*
* @ORMColumn(name="id", type="integer")
* @ORMId
* @ORMGeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var DateTime
*
* @ORMColumn(name="date", type="datetime")
*/
private $date;
/**
* @var string
* @ORMColumn(name="comment", type="text", nullable=true)
*/
private $comment;
/**
* @ORMOneToMany(targetEntity="AppBundleEntityCheckElementResult", mappedBy="checkSet", cascade={"persist"})
*/
private $checkElementResult;
/**
* @ORMOneToMany(targetEntity="AppBundleEntityCheckElementResultObservation", mappedBy="checkSet", cascade={"persist"})
*/
private $observations;
/**
* @ORMManyToOne(targetEntity="AppBundleEntityOf", inversedBy="checkSet")
* @ORMJoinColumn(name="of_id", referencedColumnName="id")
*/
private $of;
/**
* @ORMManyToOne(targetEntity="AppBundleEntityCheckPoint", inversedBy="checkSet", fetch="EAGER") 
* @ORMJoinColumn(name="checkpoint_id", referencedColumnName="id")
*/
private $checkPoint;
/**
* @ORMManyToOne(targetEntity="UserBundleEntityUser", inversedBy="checkSet")
* @ORMJoinColumn(name="operateur_id", referencedColumnName="id")
*/
private $operateur;
/**
* @ORMColumn(type="boolean", nullable=false, options={"default" : false})
*/
protected $viewed = FALSE;
/**
* @ORMColumn(type="integer", nullable=false)
*/
protected $errorCount;
/**
* @ORMManyToOne(targetEntity="AppBundleEntityFactory", inversedBy="checkSet")
* @ORMJoinColumn(name="factory_id", referencedColumnName="id")
*/
private $factory;
public function __construct($gamme = null, $of = null, $user = null){
$this->checkElementResult  = new ArrayCollection();
$this->observations        = new ArrayCollection();
$this->date                = new DateTime();
$this->errorCount          = 0;
if ($gamme != null){
$this->checkPoint = $gamme;
}
if ($of != null){
$this->of = $of;
}
if ($user != null){
$this->operateur    = $user;
$this->factory      = $user->getFactory();
}
}
public function getId(){
return $this->id;
}
public function setDate($date){
$this->date = $date;
return $this;
}
public function getDate(){
return $this->date;
}
public function setErrorCount($errorCount){
$this->errorCount = $errorCount;
return $this;
}
public function getErrorCount(){
return $this->errorCount;
}
public function setComment($comment){
$this->comment = $comment;
return $this;
}
public function getComment(){
return $this->comment;
}
public function setOperateur(User $operateur){
$this->operateur = $operateur;
return $this;
}
public function getOperateur(){
return $this->operateur;
}
public function setOf(Of $of){
$this->of = $of;
return $this;
}
public function getOf(){
return $this->of;
}
public function setFactory(Factory $factory){
$this->factory = $factory;
return $this;
}
public function getFactory(){
return $this->factory;
}
public function setCheckPoint(Checkpoint $checkPoint){
$this->checkPoint = $checkPoint;
return $this;
}
public function getCheckPoint(){
return $this->checkPoint;
}
/*------------------------------------------------------------------------CheckElementResult*/
public function addCheckElementResult(CheckElementResult $cke){
$this->checkElementResult[] = $cke;
$cke->setCheckSet($this);
return $this;
}
public function removeCheckElementResult(CheckElementResult $cke){
$this->checkElementResult->removeElement($cke);
}
public function getcheckElementResult(){
return $this->checkElementResult;
} 
/*------------------------------------------------------------------------observations*/
public function addObservations(CheckElementResultObservation $cke){
$this->observations[] = $cke;
$cke->setCheckSet($this);
return $this;
}
public function removeObservations(CheckElementResultObservation $cke){
$this->observations->removeElement($cke);
}
public function getObservations(){
return $this->observations;
}
/*-------------------------------------------------------VIEWED*/
public function setViewed($viewed){
$this->viewed = $viewed;
return $this;
}
public function getViewed(){
return $this->viewed;
}
public function isViewed(){
return $this->viewed;
}
public function countErrors(){
$err = 0;
foreach ($this->checkElementResult as $key => $ckeR) {
foreach ($ckeR->getCheckElement()->getAlert() as $key => $alert) {
if(         $alert->getOperator() == "==" && $ckeR->getValue() == $alert->getValue()){
$err++;
}elseif (   $alert->getOperator() == "!=" && $ckeR->getValue() != $alert->getValue()) {
$err++;
}elseif (   $alert->getOperator() == "<" && $ckeR->getValue() < $alert->getValue()) {
$err++;
}elseif (   $alert->getOperator() == ">" && $ckeR->getValue() > $alert->getValue()) {
$err++;
}elseif (   $alert->getOperator() == "<=" && $ckeR->getValue() <= $alert->getValue()) {
$err++;
}elseif (   $alert->getOperator() == ">=" && $ckeR->getValue() >= $alert->getValue()) {
$err++;
}
}
}
return $err;
}
public function __toString(){
return $this->of->getName().' '.$this->checkPoint->getName();
}
}

检查点:

<?php
namespace AppBundleEntity;
use DoctrineCommonCollectionsArrayCollection;
use DoctrineORMMapping as ORM;
use GedmoMappingAnnotation as Gedmo;
/**
* Checkpoint
*
* @ORMTable(name="app_checkpoint")
* @ORMEntity(repositoryClass="AppBundleRepositoryCheckpointRepository")
* @GedmoSoftDeleteable(fieldName="deletedAt", timeAware=false)
*/
class Checkpoint
{
/**
* @var int
*
* @ORMColumn(name="id", type="integer")
* @ORMId
* @ORMGeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORMColumn(name="name", type="string", length=255)
*/
private $name;
/**
* @var string
*
* @ORMColumn(name="description", type="string", length=255, nullable=true)
*/
private $description;
/**
* @ORMOneToMany(targetEntity="AppBundleEntityCheckElement", mappedBy="checkpoint",cascade={"persist"}, orphanRemoval=true)
* @ORMOrderBy({"position" = "ASC"})
*/
private $checkElements;
/**
* @ORMOneToMany(targetEntity="AppBundleEntityOperation", mappedBy="checkpoint",cascade={"persist"})
*/
private $operation;
/**
* @ORMManyToOne(targetEntity="AppBundleEntityFactory", inversedBy="checkpoints")
* @ORMJoinColumn(name="factory_id", referencedColumnName="id")
*/
private $factory;
/**
* @ORMOneToMany(targetEntity="AppBundleEntityCheckSet", mappedBy="checkPoint")
*/
private $checkSet;
/**
* @ORMOneToMany(targetEntity="AppBundleEntityCheckListOf", mappedBy="checkPoint")
*/
private $checkListOf;
/**
* @ORMColumn(type="datetime", nullable=true)
*/
private $deletedAt;
public function __construct(){
$this->checkElements    = new ArrayCollection();
}
public function getId(){
return $this->id;
}
public function setName($name){
$this->name = $name;
return $this;
}
public function getName(){
return $this->name;
}
public function setDescription($description){
$this->description = $description;
return $this;
}
public function getDescription(){
return $this->description;
}
public function getFactory(){
return $this->factory;
}
public function setFactory($factory){
$this->factory = $factory;
}
/*------------------------------------------------------------------------Checkelements*/
public function addCheckElement(CheckElement $cke){
$this->checkElements[] = $cke;
$cke->setCheckpoint($this);
return $this;
}
public function removeCheckElement(CheckElement $cke){
$this->checkElements->removeElement($cke);
}
public function getCheckElements(){
return $this->checkElements;
}
public function __toString(){
return $this->name;
}
}

问题可能是因为软删除,但我不确定。。。我正在调用的控制器(notificationsAction)嵌入在我的头中。

在此页面(通知区域)中,我希望显示可能已删除的对象。当我想要显示的checkpoint(与校验集对象相关的)已被删除时出现问题

<!-- NOTIFICATIONS -->
{{ render(controller('AppBundle:Home:notifications', {'request': app.request})) }}

您的问题实际上与此处相同。

您的类名是Checkpoint,我猜该文件名为Checkpoint.php(请注意,如果您在windows上开发,则文件名不区分大小写)。全部为小写。

在您的CheckSet类中,您有

/**
* @ORMManyToOne(targetEntity="AppBundleEntityCheckPoint", inversedBy="checkSet", fetch="EAGER") 
* @ORMJoinColumn(name="checkpoint_id", referencedColumnName="id")
*/
private $checkPoint;

targetEntity"AppBundle\Entity\CheckPoint">,资本p

问题是,正因为如此,条令为一个新表创建了一个新的别名(php比较是区分大小写的github链接)。

要解决此问题,请将类名和文件更改为CheckPoint,大写p

class CheckPoint
{

相关内容

  • 没有找到相关文章

最新更新