在我向我的实体添加OneToMany协会后,魔术查找器以及从数据库获取结果的任何方法都已停止,并且我收到致命错误。
这是第一个实体(Slaplans):
namespace ZC\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use ZC\Entity\Slaholidaylinks;
/**
* Slaplans
*
* @Table(name="slaplans")
* @Entity(repositoryClass="Repositories\Slaplans")
*/
class Slaplans
{
/**
* @var integer $slaplanid
*
* @Column(name="slaplanid", type="integer", nullable=false)
* @Id
* @GeneratedValue(strategy="IDENTITY")
*/
private $slaplanid;
/**
* @var integer $slascheduleid
*
* @Column(name="slascheduleid", type="integer", nullable=false)
*/
private $slascheduleid;
/**
* @var string $title
*
* @Column(name="title", type="string", length=255, nullable=false)
*/
private $title;
/**
* @var float $overduehrs
*
* @Column(name="overduehrs", type="float", nullable=false)
*/
private $overduehrs;
/**
* @var float $resolutionduehrs
*
* @Column(name="resolutionduehrs", type="float", nullable=false)
*/
private $resolutionduehrs;
/**
* @var smallint $isenabled
*
* @Column(name="isenabled", type="smallint", nullable=false)
*/
private $isenabled;
/**
* @var integer $sortorder
*
* @Column(name="sortorder", type="integer", nullable=false)
*/
private $sortorder;
/**
* @var smallint $ruletype
*
* @Column(name="ruletype", type="smallint", nullable=false)
*/
private $ruletype;
/**
* @var integer $dateline
*
* @Column(name="dateline", type="integer", nullable=false)
*/
private $dateline;
/**
* @OneToMany(targetEntity="Slaholidaylinks" , mappedBy="planid", cascade={"persist"} )
*/
private $holidaylinks;
public function __construct(){
$this->holidaylinks= new ArrayCollection();
}
/**
* Get slaplanid
*
* @return integer $slaplanid
*/
public function getSlaplanid()
{
return $this->slaplanid;
}
/**
* Set slascheduleid
*
* @param integer $slascheduleid
*/
public function setSlascheduleid($slascheduleid)
{
$this->slascheduleid = $slascheduleid;
}
/**
* Get slascheduleid
*
* @return integer $slascheduleid
*/
public function getSlascheduleid()
{
return $this->slascheduleid;
}
/**
* Set title
*
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* Get title
*
* @return string $title
*/
public function getTitle()
{
return $this->title;
}
/**
* Set overduehrs
*
* @param float $overduehrs
*/
public function setOverduehrs($overduehrs)
{
$this->overduehrs = $overduehrs;
}
/**
* Get overduehrs
*
* @return float $overduehrs
*/
public function getOverduehrs()
{
return $this->overduehrs;
}
/**
* Set resolutionduehrs
*
* @param float $resolutionduehrs
*/
public function setResolutionduehrs($resolutionduehrs)
{
$this->resolutionduehrs = $resolutionduehrs;
}
/**
* Get resolutionduehrs
*
* @return float $resolutionduehrs
*/
public function getResolutionduehrs()
{
return $this->resolutionduehrs;
}
/**
* Set isenabled
*
* @param smallint $isenabled
*/
public function setIsenabled($isenabled)
{
$this->isenabled = $isenabled;
}
/**
* Get isenabled
*
* @return smallint $isenabled
*/
public function getIsenabled()
{
return $this->isenabled;
}
/**
* Set sortorder
*
* @param integer $sortorder
*/
public function setSortorder($sortorder)
{
$this->sortorder = $sortorder;
}
/**
* Get sortorder
*
* @return integer $sortorder
*/
public function getSortorder()
{
return $this->sortorder;
}
/**
* Set ruletype
*
* @param smallint $ruletype
*/
public function setRuletype($ruletype)
{
$this->ruletype = $ruletype;
}
/**
* Get ruletype
*
* @return smallint $ruletype
*/
public function getRuletype()
{
return $this->ruletype;
}
/**
* Set dateline
*
* @param integer $dateline
*/
public function setDateline($dateline)
{
$this->dateline = $dateline;
}
/**
* Get dateline
*
* @return integer $dateline
*/
public function getDateline()
{
return $this->dateline;
}
/*
* Get Holiday links
* @return ArrayCollection $holidaylinks
*/
public function getHolidaylinks()
{
return $this->holidaylinks;
}
/*
public function addHolidaylinks(Slaholidaylinks $aholidaylink)
{
$this->holidaylinks[]=$aholidaylink;
}*/
}
/**
* @var string $title
*
* @Column(name="title", type="string", length=255, nullable=false)
*/
private $title;
/**
* @var float $overduehrs
*
* @Column(name="overduehrs", type="float", nullable=false)
*/
private $overduehrs;
/**
* @var float $resolutionduehrs
*
* @Column(name="resolutionduehrs", type="float", nullable=false)
*/
private $resolutionduehrs;
/**
* @var smallint $isenabled
*
* @Column(name="isenabled", type="smallint", nullable=false)
*/
private $isenabled;
/**
* @var integer $sortorder
*
* @Column(name="sortorder", type="integer", nullable=false)
*/
private $sortorder;
/**
* @var smallint $ruletype
*
* @Column(name="ruletype", type="smallint", nullable=false)
*/
private $ruletype;
/**
* @var integer $dateline
*
* @Column(name="dateline", type="integer", nullable=false)
*/
private $dateline;
/**
* @OneToMany(targetEntity="Slaholidaylinks" , mappedBy="planid", cascade={"persist"} )
*/
private $holidaylinks;
public function __construct(){
$this->holidaylinks= new ArrayCollection();
}
/**
* Get slaplanid
*
* @return integer $slaplanid
*/
public function getSlaplanid()
{
return $this->slaplanid;
}
/**
* Set slascheduleid
*
* @param integer $slascheduleid
*/
public function setSlascheduleid($slascheduleid)
{
$this->slascheduleid = $slascheduleid;
}
/**
* Get slascheduleid
*
* @return integer $slascheduleid
*/
public function getSlascheduleid()
{
return $this->slascheduleid;
}
/**
* Set title
*
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* Get title
*
* @return string $title
*/
public function getTitle()
{
return $this->title;
}
/**
* Set overduehrs
*
* @param float $overduehrs
*/
public function setOverduehrs($overduehrs)
{
$this->overduehrs = $overduehrs;
}
/**
* Get overduehrs
*
* @return float $overduehrs
*/
public function getOverduehrs()
{
return $this->overduehrs;
}
/**
* Set resolutionduehrs
*
* @param float $resolutionduehrs
*/
public function setResolutionduehrs($resolutionduehrs)
{
$this->resolutionduehrs = $resolutionduehrs;
}
/**
* Get resolutionduehrs
*
* @return float $resolutionduehrs
*/
public function getResolutionduehrs()
{
return $this->resolutionduehrs;
}
/**
* Set isenabled
*
* @param smallint $isenabled
*/
public function setIsenabled($isenabled)
{
$this->isenabled = $isenabled;
}
/**
* Get isenabled
*
* @return smallint $isenabled
*/
public function getIsenabled()
{
return $this->isenabled;
}
/**
* Set sortorder
*
* @param integer $sortorder
*/
public function setSortorder($sortorder)
{
$this->sortorder = $sortorder;
}
/**
* Get sortorder
*
* @return integer $sortorder
*/
public function getSortorder()
{
return $this->sortorder;
}
/**
* Set ruletype
*
* @param smallint $ruletype
*/
public function setRuletype($ruletype)
{
$this->ruletype = $ruletype;
}
/**
* Get ruletype
*
* @return smallint $ruletype
*/
public function getRuletype()
{
return $this->ruletype;
}
/**
* Set dateline
*
* @param integer $dateline
*/
public function setDateline($dateline)
{
$this->dateline = $dateline;
}
/**
* Get dateline
*
* @return integer $dateline
*/
public function getDateline()
{
return $this->dateline;
}
/*
* Get Holiday links
* @return ArrayCollection $holidaylinks
*/
public function getHolidaylinks()
{
return $this->holidaylinks;
}
/*
public function addHolidaylinks(Slaholidaylinks $aholidaylink)
{
$this->holidaylinks[]=$aholidaylink;
}*/
}
这是第二个实体(Slaholidaylinks):
<?php
namespace ZC\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use ZC\Entity\Slaplans;
/**
* Slaholidaylinks
*
* @Table(name="slaholidaylinks")
* @Entity(repositroyClass="Repositories\Slaholidaylinks")
*/
class Slaholidaylinks
{
/**
* @var integer $slaholidaylinkid
*
* @Column(name="slaholidaylinkid", type="integer", nullable=false)
* @Id
* @GeneratedValue(strategy="IDENTITY")
*/
private $slaholidaylinkid;
/**
* @var Slaplans $slaholidayid
* @ManyToOne(targetEntity="Slaplans" , inversedBy="holidaylinks" )
* @JoinColumn(name='slaplanid',referencedColumnName='slaplanid')
*/
private $slaplanid;
/**
* @var integer $slaholidayid
*
* @Column(name="slaholidayid", type="integer", nullable=false)
*/
private $slaholidayid;
/**
* Get slaholidaylinkid
*
* @return integer $slaholidaylinkid
*/
public function getSlaholidaylinkid()
{
return $this->slaholidaylinkid;
}
/**
* Set slaplanid
*
* @param integer $slaplanid
*/
public function setSlaplanid(Slaplans $slaplanid)
{
$this->slaplanid = $slaplanid;
}
/**
* Get slaplanid
*
* @return integer $slaplanid
*/
public function getSlaplanid()
{
return $this->slaplanid;
}
/**
* Set slaholidayid
*
* @param integer $slaholidayid
*/
public function setSlaholidayid($slaholidayid)
{
$this->slaholidayid = $slaholidayid;
}
/**
* Get slaholidayid
*
* @return integer $slaholidayid
*/
public function getSlaholidayid()
{
return $this->slaholidayid;
}
}
我尝试使用以下代码获取Slaplans实体时出现致命错误:
$默认= $这 - &GT; _em-&GT; getRepository( 'ZC \实体\ Slaplans') - &GT; findOneBySlaplanid($ planid);
我尝试了queryBuilder,但是当我运行getResult函数时,我也收到错误。
请帮帮我。
答案 0 :(得分:0)
对于holidaylinks变量(Slaplans Entity):
/**
*
* @param \Doctrine\Common\Collections\Collection
*
* @OneToMany(targetEntity="Slaholidaylinks",mappedBy="planid", cascade={"persist"})
*/
private $holidaylinks;
对于planid变量(Slaholidaylinks Entity):
/**
*
* @var Slaplans
* @ManyToOne(targetEntity="Slaplans",inversedBy="holidaylinks")
* @JoinColumns({
* @JoinColumn(name="slaplanid", referencedColumnName="slaplanid")
* })
*/
private $planid;
这就是我解决问题的方法:)