我有两个实体" OfferStage和Entreprise"与ManyToOne和OneToMany的关系,以及显示" offrestage"我喜欢展示每个" Entreprise"
的徽标实体/ OffreStage
class OffreStage
{
/...
/**
*
*
* @ORM\ManyToOne(targetEntity="UserBundle\Entity\Entreprise", inversedBy="offres", cascade={"persist", "merge"})
* @ORM\JoinColumn(name="entreprise_id", referencedColumnName="id")
*/
protected $entreprise;
实体/企业公司
class Entreprise extends User
{
/..
/**
* @ORM\OneToMany(targetEntity="Gestion\StageBundle\Entity\OffreStage", mappedBy="entreprise")
*/
protected $offres;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $path;
控制器
class DefaultController extends Controller
{
public function indexAction()
{
return $this->render('FrontBundle:Default:index.html.twig');
}
public function listeStagesShowAction()
{
$em = $this->getDoctrine()->getManager();
$offreStages = $em->getRepository('StageBundle:OffreStage')- >findAll();
return $this->render('FrontBundle:Stage:listeStage.html.twig', array(
'offreStages' => $offreStages,
));
} }
答案 0 :(得分:0)
它只是来自数据库的问题,它找到了具有空值的数据