1. <i id='A7Kxh'><tr id='A7Kxh'><dt id='A7Kxh'><q id='A7Kxh'><span id='A7Kxh'><b id='A7Kxh'><form id='A7Kxh'><ins id='A7Kxh'></ins><ul id='A7Kxh'></ul><sub id='A7Kxh'></sub></form><legend id='A7Kxh'></legend><bdo id='A7Kxh'><pre id='A7Kxh'><center id='A7Kxh'></center></pre></bdo></b><th id='A7Kxh'></th></span></q></dt></tr></i><div id='A7Kxh'><tfoot id='A7Kxh'></tfoot><dl id='A7Kxh'><fieldset id='A7Kxh'></fieldset></dl></div>

        <small id='A7Kxh'></small><noframes id='A7Kxh'>

        <tfoot id='A7Kxh'></tfoot>

        <legend id='A7Kxh'><style id='A7Kxh'><dir id='A7Kxh'><q id='A7Kxh'></q></dir></style></legend>
          <bdo id='A7Kxh'></bdo><ul id='A7Kxh'></ul>

        多对一关联映射到 Doctrine 2 中的类表继承实体

        ManyToOne association mapping to a Class Table Inheritance entity in Doctrine 2(多对一关联映射到 Doctrine 2 中的类表继承实体)
      2. <i id='4Ma9a'><tr id='4Ma9a'><dt id='4Ma9a'><q id='4Ma9a'><span id='4Ma9a'><b id='4Ma9a'><form id='4Ma9a'><ins id='4Ma9a'></ins><ul id='4Ma9a'></ul><sub id='4Ma9a'></sub></form><legend id='4Ma9a'></legend><bdo id='4Ma9a'><pre id='4Ma9a'><center id='4Ma9a'></center></pre></bdo></b><th id='4Ma9a'></th></span></q></dt></tr></i><div id='4Ma9a'><tfoot id='4Ma9a'></tfoot><dl id='4Ma9a'><fieldset id='4Ma9a'></fieldset></dl></div>

        <small id='4Ma9a'></small><noframes id='4Ma9a'>

            <bdo id='4Ma9a'></bdo><ul id='4Ma9a'></ul>
            <tfoot id='4Ma9a'></tfoot><legend id='4Ma9a'><style id='4Ma9a'><dir id='4Ma9a'><q id='4Ma9a'></q></dir></style></legend>

                  <tbody id='4Ma9a'></tbody>

                • 本文介绍了多对一关联映射到 Doctrine 2 中的类表继承实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个 Author 实体,它是一个包含 AuthorUser 和一个 AuthorGroup 的类表继承.

                  I have an Author entity, which is a Class Table Inheritance containing an AuthorUser and an AuthorGroup.

                  /**
                   * Author
                   *
                   * @ORMTable
                   * @ORMEntity
                   * @ORMInheritanceType("JOINED")
                   * @ORMDiscriminatorColumn(name="type", type="string")
                   * @ORMDiscriminatorMap({"user" = "AuthorUser", "group" = "AuthorGroup"})
                   */
                  class Author {
                      // ...
                  }
                  

                  AuthorUser 与我的 User 实体相关,AuthorGroup 与我的 Group 实体相关.

                  AuthorUser relates to my User entity and AuthorGroup to my Group entity.

                  class AuthorUser extends Author
                  {
                      /**
                       * @var User
                       *
                       * @ORMManyToOne(targetEntity="User", inversedBy="?????")
                       * @ORMJoinColumn(name="user_id", referencedColumnName="id")
                       */
                      protected $user;
                  }
                  
                  class AuthorGroup extends Author
                  {
                      /**
                       * @var Group
                       *
                       * @ORMManyToOne(targetEntity="Group", inversedBy="?????")
                       * @ORMJoinColumn(name="group_id", referencedColumnName="id")
                       */
                      protected $user;
                  }
                  

                  我不知道如何反转这个.无论如何,问题是我必须将此 CTI 添加到我的 Article 实体字段中.我如何使用 ManyToOne 与这篇文章实体字段相关联?

                  I have no idea how to inverse this. Anyway, the problem is that i have to add this CTI to my Article entity field. How can i relate using ManyToOne to this Article entity field?

                  class Article
                  {
                      /**
                       * @var Author
                       *
                       * @ORMManyToOne(targetEntity="Author", inversedBy="?????????")
                       * @ORMJoinColumn(name="author_id", referencedColumnName="id")
                       */
                      protected $author;
                  }
                  

                  我不确定如何使其尽可能透明.当我创建一个新的 Article 时,我需要向 author 字段提供一个 UserGroup 对象.我遵循了这种行为,但似乎没有帮助.它变得更加复杂.

                  I'm not sure how to make this as transparent as possible. When i create a new Article, i need to provide either an User or Group object to the author field. I followed this behavior, but it doesn't seem to help. It gets even more complicated.

                  推荐答案

                  一种解决方案是始终拥有 AuthorGroups,即使只有一个作者.

                  One solution could be to always have AuthorGroups, even when there's only one Author.

                  否则,看看 https://github.com/FabienPennequin/DoctrineExtensions-Rateable

                  您也许可以使用该代码来提供类似的 Authored 接口,该接口可以区分 AuthorUser 和 AuthorGroup.

                  You might be able to use that code to provide a similar Authored interface that can discriminate between the AuthorUser and AuthorGroup.

                  这篇关于多对一关联映射到 Doctrine 2 中的类表继承实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                    • <small id='9rTSt'></small><noframes id='9rTSt'>

                        <tbody id='9rTSt'></tbody>
                      <i id='9rTSt'><tr id='9rTSt'><dt id='9rTSt'><q id='9rTSt'><span id='9rTSt'><b id='9rTSt'><form id='9rTSt'><ins id='9rTSt'></ins><ul id='9rTSt'></ul><sub id='9rTSt'></sub></form><legend id='9rTSt'></legend><bdo id='9rTSt'><pre id='9rTSt'><center id='9rTSt'></center></pre></bdo></b><th id='9rTSt'></th></span></q></dt></tr></i><div id='9rTSt'><tfoot id='9rTSt'></tfoot><dl id='9rTSt'><fieldset id='9rTSt'></fieldset></dl></div>

                        • <bdo id='9rTSt'></bdo><ul id='9rTSt'></ul>

                          <tfoot id='9rTSt'></tfoot>
                            <legend id='9rTSt'><style id='9rTSt'><dir id='9rTSt'><q id='9rTSt'></q></dir></style></legend>