0
我一直在掙扎學說,我已經得到了博客文章的實體,它引用的意見和它拋出以下錯誤: 注意:未定義指數:POST_ID學說2協會投擲警告
這也得到所有的評論,無論post_id。這裏是我的映射:
/**
* @OneToMany(targetEntity="CommentsBundle\Entities\Comments", mappedBy="post_id")
*/
protected $comments;
編輯
這裏的評論實體:
<?php
namespace CommentsBundle\Entities;
use Doctrine\ORM\Mapping AS ORM;
/**
* @Entity @Table(name="comments")
**/
class Comments
{
/** @Id @Column(type="integer") @GeneratedValue */
private $id;
/** @Column(type="string") */
protected $name;
/** @Column(type="string") */
protected $email;
/** @Column(type="string") */
protected $content;
/** @Column(type="string") */
protected $date;
/** @Column(type="integer") */
protected $user_id;
/** @Column(type="integer") */
protected $post_id;
/**
* @ORM\ManyToOne(targetEntity="ContentBundle\Entities\Posts", inversedBy="comments")
* @ORM\JoinColumn(name="post_id", referencedColumnName="id")
*/
protected $post;
public function setId($id)
{
$this->id = $id;
return $this;
}
public function getId()
{
return $this->id;
}
public function setName($name)
{
$this->name = $name;
return $this;
}
public function getName()
{
return $this->name;
}
public function setEmail($email)
{
$this->email = $email;
return $this;
}
public function getEmail()
{
return $this->email;
}
public function setContent($content)
{
$this->content = $content;
return $this;
}
public function getContent()
{
return $this->content;
}
public function setDate($date)
{
$this->date = $date;
return $this;
}
public function getDate()
{
return $this->date;
}
public function setUser_id($user_id)
{
$this->user_id = $user_id;
}
public function getUser_id()
{
return $this->user_id;
}
public function setPost_id($post_id)
{
$this->post_id = $post_id;
return $this;
}
public function getPost_id()
{
return $this->post_id;
}
}
提前感謝!
是不是在Symfony2(你似乎使用)中的實體目錄稱爲「實體」而不是「實體」? – Jivan
我實際上使用Silex,我的大部分代碼都是這樣保存的 src/BundleName/Controllers src/BundleName/Entities src/BundleName/Views –
ok。你關係的另一面是什麼?你可以編輯你的帖子來顯示這個? – Jivan