我有beetween「地段」和「BailProprietaire」一個多對多關係多對多不聽者正與虛擬財產
當我得到一個實體「BailProprietaire」,我看到的實體「大量」掛 但是當我實體 「地段」,我沒有看到實體 「BailProprietaire」 鏈接
在lot.orm.yml,我有:
AppBundle\Entity\Lot:
type: entity
repositoryClass: AppBundle\Repository\LotRepository
table: lot
....
....
manyToMany:
bauxProprietaire:
targetEntity: BailProprietaire
mappedBy: lots
在bailProprietaire.orm.yml,我有:
AppBundle\Entity\BailProprietaire:
type: entity
table: bail_proprietaire
repositoryClass: AppBundle\Repository\BailProprietaireRepository
....
....
manyToMany:
lots:
targetEntity: Lot
inversedBy: bauxProprietaire
fetch: LAZY
joinTable:
name: bail_proprietaire_lots
joinColumns:
bail_id:
referencedColumnName: id
inverseJoinColumns:
lot_id:
referencedColumnName: id
lifecycleCallbacks: { }
你看到我想念的東西嗎?
感謝
編輯:添加PHP代碼實體
Lot.php
class Lot
{
/**
* @var integer
*/
private $id;
/**
* @var \Doctrine\Common\Collections\Collection
*/
private $bauxProprietaire;
/**
* Constructor
*/
public function __construct()
{
$this->bauxProprietaire = new ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Add bauxProprietaire
*
* @param \AppBundle\Entity\BailProprietaire $bauxProprietaire
*
* @return Lot
*/
public function addBauxProprietaire(\AppBundle\Entity\BailProprietaire $bauxProprietaire)
{
$this->bauxProprietaire[] = $bauxProprietaire;
return $this;
}
/**
* Remove bauxProprietaire
*
* @param \AppBundle\Entity\BailProprietaire $bauxProprietaire
*/
public function removeBauxProprietaire(\AppBundle\Entity\BailProprietaire $bauxProprietaire)
{
$this->bauxProprietaire->removeElement($bauxProprietaire);
}
/**
* Get bauxProprietaire
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getBauxProprietaire()
{
return $this->bauxProprietaire;
}
}
BailProprietaire.php
class BailProprietaire
{
/**
* @var integer
*/
private $id;
/**
* @var \Doctrine\Common\Collections\Collection
*/
private $lots;
/**
* Constructor
*/
public function __construct()
{
$this->lots = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Add lot
*
* @param \AppBundle\Entity\Lot $lot
*
* @return BailProprietaire
*/
public function addLot(\AppBundle\Entity\Lot $lot)
{
$this->lots[] = $lot;
return $this;
}
/**
* Remove lot
*
* @param \AppBundle\Entity\Lot $lot
*/
public function removeLot(\AppBundle\Entity\Lot $lot)
{
$this->lots->removeElement($lot);
}
/**
* Get lots
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getLots()
{
return $this->lots;
}
}
編輯2:其實,它的工作原理,但不與聆聽者
事實上,當我得到「很多」時,我看到實體「BailProprietaire」,但當我刷新數據時,我有一個監聽器。在這個監聽器,我稱之爲「Lot.php」的虛擬propertie我哪裏有:
if (!empty($this->bauxProprietaire)) {
....
} else {
....
}
但$這個 - > bauxProprietaire總是空
你能告訴我們你的PHP代碼的實體? –