<bdo id='PGbU7'></bdo><ul id='PGbU7'></ul>
    1. <tfoot id='PGbU7'></tfoot>

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

    3. <small id='PGbU7'></small><noframes id='PGbU7'>

    4. Doctrine 2 WHERE IN 子句使用实体集合

      时间:2024-08-10
    5. <legend id='jiyDt'><style id='jiyDt'><dir id='jiyDt'><q id='jiyDt'></q></dir></style></legend>
      1. <i id='jiyDt'><tr id='jiyDt'><dt id='jiyDt'><q id='jiyDt'><span id='jiyDt'><b id='jiyDt'><form id='jiyDt'><ins id='jiyDt'></ins><ul id='jiyDt'></ul><sub id='jiyDt'></sub></form><legend id='jiyDt'></legend><bdo id='jiyDt'><pre id='jiyDt'><center id='jiyDt'></center></pre></bdo></b><th id='jiyDt'></th></span></q></dt></tr></i><div id='jiyDt'><tfoot id='jiyDt'></tfoot><dl id='jiyDt'><fieldset id='jiyDt'></fieldset></dl></div>
          <tfoot id='jiyDt'></tfoot>

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

                <bdo id='jiyDt'></bdo><ul id='jiyDt'></ul>
                  <tbody id='jiyDt'></tbody>
                本文介绍了Doctrine 2 WHERE IN 子句使用实体集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试在 Doctrine 2 中构建一个查询,以查找与任何给定 VacancyWorkingHours 实体相关的所有 Vacancy 实体.

                I'm attempting to build a query in Doctrine 2 that finds all Vacancy entities which are related to any of the given VacancyWorkingHours entities.

                Vacancy 实体如下所示:

                /**
                 * Vacancy
                 *
                 * @ORMTable(name="vacancy")
                 * @ORMEntity(repositoryClass="JaikDeanCareersBundleEntityVacancyRepository")
                 */
                class Vacancy
                {
                    /**
                     * @var integer
                     *
                     * @ORMColumn(name="id", type="integer")
                     * @ORMId
                     * @ORMGeneratedValue(strategy="AUTO")
                     */
                    private $id;
                
                    /**
                     * @var VacancyWorkingHours
                     *
                     * @ORMManyToOne(targetEntity="VacancyWorkingHours", inversedBy="vacancies")
                     * @ORMJoinColumn(name="vacancy_working_hours_id", referencedColumnName="id")
                     **/
                    private $workingHours;
                
                    /* Other fields and methods are inconsequential */
                }
                

                我的查询当前如下所示,但由于 where 子句,没有返回任何结果.在此示例中,$workingHours 是一个 DoctrineCommonCollectionsArrayCollection 实例,其中包含许多 VacancyWorkingHours 实体

                My query currently looks as follows, but returns no results because of the where clause. In this example, $workingHours is a DoctrineCommonCollectionsArrayCollection instance containing a number of VacancyWorkingHours entities

                $q = $this->createQueryBuilder('v')
                    ->select('v')
                    ->andWhere('v.workingHours IN (:workingHours)')
                    ->setParameter('workingHours', $workingHours->toArray());
                ;
                

                推荐答案

                一个 拉取请求 我提出了这个问题已合并到 Doctrine ORM 2.5 中,因此您现在可以简单地执行此操作:

                A pull request I made about this has been merged into Doctrine ORM 2.5, so you can simply do this now:

                $q = $this->createQueryBuilder('v')
                    ->select('v')
                    ->andWhere('v.workingHours IN (:workingHours)')
                    ->setParameter('workingHours', $workingHours);
                ;
                

                最新版本的 Doctrine 现在允许集合参数,并且会自动使用每个集合条目的主键.

                The latest version of Doctrine now allows collection parameters and will automatically make use of the primary key of each of the collection entries.

                这篇关于Doctrine 2 WHERE IN 子句使用实体集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:在教义中使用列值作为数组索引 下一篇:MYSQL DATETIME 格式不正确

                相关文章

              • <tfoot id='5pD6p'></tfoot>

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

                • <bdo id='5pD6p'></bdo><ul id='5pD6p'></ul>

                  <small id='5pD6p'></small><noframes id='5pD6p'>

                    <legend id='5pD6p'><style id='5pD6p'><dir id='5pD6p'><q id='5pD6p'></q></dir></style></legend>