我在symfony的项目中苦苦挣扎。 我有一个实体内容,我的数据库内容中有一个表格,可以保存内容。 每个内容都有一个id。 如果有人想看到他们必须通过提交电子邮件 strong>来查询特定内容,我需要将所有电子邮件 strong>与 特定ID内容相关联 EM> strong>即可。 我不想创建一个新实体只是为了保存请求电子邮件。 有没有办法用教条注释创建/关联新表。 他们必须处于多对一 strong>的关系中。 或者是否有另一种简单的方法来保存电子邮件请求。 这是我的代码,但不起作用。 p>
感谢您的时间。 p>
div>
/ **
* @ORM \ Table(name =“content”)
* @ORM \ Entity(repositoryClass =“myBundle \ Repository \ ContentRepository”)\ n * /
n class Content {
/ **
* @var integer
* @ORM \ Column(name =“id”,type =“integer”)
* @ORM \ Id
* @ ORM \ GeneratedValue(strategy =“AUTO”)
* /
private $ id;
/ **
* @var string $ nome
* @ORM \ ManyToOne(targetEntity =“Content”)\ n * @ORM \ Column(name =“email_request”,type =“string”,length = 255,unique = false,nullable = false)
* /
private $ emailRequest;
code> pre >
I'm struggling with this, in my project in symfony. I have a entity content, with doctrine i have a table in my db content, that saves contents. Every content has an id. If anyone wants to see a specific content they have to request it by submitting an email, I need to associate all the emails to the specific id content. I dont want to create a new entity just to save the request emails. Is there a way to create/associate a new table with doctrine annotations. They have to be in a relation many-to-one. Or is there another simple way to save the email requests. This is the code I have, but is not working.
/**
* @ORM\Table(name="content")
* @ORM\Entity(repositoryClass="myBundle\Repository\ContentRepository")
*/
class Content{
/**
* @var integer
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string $nome
* @ORM\ManyToOne(targetEntity="Content")
* @ORM\Column(name="email_request", type="string", length=255, unique=false, nullable=false )
*/
private $emailRequest;
Thanks for your time.