douyi6922 2014-07-13 18:39
浏览 72


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.

  • 写回答

1条回答 默认 最新

  • doufuxing8691 2014-07-14 07:02

    Your $emailRequest wouldn't be defined as Column if you want it to map entity. You need to define @ORM\JoinColumn instead.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



    • ¥15 编译arm板子的gcc
    • ¥20 C语言用栈实现无向图邻接矩阵广度优先遍历
    • ¥15 C++代码报错问题,c++20协程
    • ¥15 c++图Djikstra算法求最短路径
    • ¥15 Linux操作系统中的,管道通信问题
    • ¥15 ansible tower 卡住
    • ¥15 等间距平面螺旋天线方程式
    • ¥15 通过链接访问,显示514或不是私密连接
    • ¥100 系统自动弹窗,键盘一接上就会
    • ¥50 股票交易系统设计(sql语言)