<tfoot id='2Kv8Q'></tfoot>
  • <legend id='2Kv8Q'><style id='2Kv8Q'><dir id='2Kv8Q'><q id='2Kv8Q'></q></dir></style></legend>

      • <bdo id='2Kv8Q'></bdo><ul id='2Kv8Q'></ul>

      <small id='2Kv8Q'></small><noframes id='2Kv8Q'>

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

        如何在不加入doctrine2的情况下获得id?

        时间:2023-08-20

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

          1. <legend id='uNOPG'><style id='uNOPG'><dir id='uNOPG'><q id='uNOPG'></q></dir></style></legend>

              <tfoot id='uNOPG'></tfoot>
            • <small id='uNOPG'></small><noframes id='uNOPG'>

                <bdo id='uNOPG'></bdo><ul id='uNOPG'></ul>
                  <tbody id='uNOPG'></tbody>
                • 本文介绍了如何在不加入doctrine2的情况下获得id?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有这样的实体:

                  /**
                   *
                   * @Table(name="table")
                   * @Entity
                   */
                   class Table {
                  
                      /**
                       * @Column(type="integer")
                       * @Id
                       * @GeneratedValue(strategy="IDENTITY")
                       */
                       private $id;
                  
                  
                      /**
                       * @ManyToOne(targetEntity="EntitiesUsers")
                       * @joinColumn(name="userId", referencedColumnName="id")
                       */
                       private $User;
                  
                  
                      /**
                       * @Column(type="string")
                       */
                       private $text;
                  
                  
                  }
                  

                  如果我这样做$q->getQuery()->getSingleResult()->getUser()->getUserId()

                  doctrine 生成查询,如:

                  doctrine generate query like:

                  SELECT * FROM table t INNER JOIN users u ON u.id = t.userId WHERE id = 100
                  

                  但如果我不需要表用户,如何获取用户 ID.

                  but if i don`t need table users, how to get an userId.

                  在纯 SQL 中,我可以

                  In pure SQL i can just

                  SELECT * FROM table WHERE id = 100
                  

                  并在不加入用户表的情况下获取 userId.

                  and get userId without join users table.

                  推荐答案

                  您可能还想查看 IDENTITY() 函数(Doctrine version >2.2).

                  You may also want to look at the IDENTITY() function (Doctrine version >2.2).

                  示例:

                  SELECT IDENTITY(t.User) AS user_id from Table
                  

                  应该返回:

                  [ ['user_id' => 1], ['user_id' => 2], ... ]
                  

                  另见:http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/dql-doctrine-query-language.html#dql-functions

                  这篇关于如何在不加入doctrine2的情况下获得id?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Doctrine2 插入和检索新的插入 ID 下一篇:错误:预期的 DoctrineORMQueryLexer::T_WITH,“ON"

                  相关文章

                  <tfoot id='HKjS3'></tfoot>

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

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

                      <bdo id='HKjS3'></bdo><ul id='HKjS3'></ul>

                    1. <legend id='HKjS3'><style id='HKjS3'><dir id='HKjS3'><q id='HKjS3'></q></dir></style></legend>