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

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

      1. <tfoot id='XCdbQ'></tfoot>

        实施“如果存在则更新"在学说 ORM

        implementing quot;update if existsquot; in Doctrine ORM(实施“如果存在则更新在学说 ORM)

        <legend id='s9eDp'><style id='s9eDp'><dir id='s9eDp'><q id='s9eDp'></q></dir></style></legend>

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

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

              <tfoot id='s9eDp'></tfoot>
                <bdo id='s9eDp'></bdo><ul id='s9eDp'></ul>

                  本文介绍了实施“如果存在则更新"在学说 ORM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试在一个事务中INSERT OR UPDATE IF EXISTS.

                  I am trying to INSERT OR UPDATE IF EXISTS in one transaction.

                  mysql 中,我通常会使用 DUPLICATE KEY(UPDATE ON DUPLICATE KEY".)我知道许多使用各种 SQL 变体和子查询,但我试图在 Doctrine (PHP ORM) 中实现它.似乎有 Doctrine 方法可以做到这一点,因为它的功能如此丰富,但我没有找到任何东西.出于某种原因,使用 PHP ORM 包会出现这种问题吗?或者是否有任何 Doctrine 专家知道如何通过黑客或任何方式实现这一目标?

                  in mysql, I would generally use DUPLICATE KEY ("UPDATE ON DUPLICATE KEY".) I'm aware of many solutions to this problem using various SQL variants and sub-queries, but I'm trying to implement this in Doctrine (PHP ORM). It seems there would be Doctrine methods for doing this since it's so feature packed, but I'm not finding anything. Is this sort of thing a problem using PHP ORM packages for some reason? Or do any Doctrine experts know how to achieve this through hacks or any means?

                  推荐答案

                  根据 https://www.vivait.co.uk/labs/updating-entities-when-an-insert-has-a-duplicate-key-in-教义 这可以通过 $entityManager->merge() 来实现.

                  According to https://www.vivait.co.uk/labs/updating-entities-when-an-insert-has-a-duplicate-key-in-doctrine this can be achieved with $entityManager->merge().

                  $entity = new Table();
                  $entity->setId(1);
                  $entity->setValue('TEST');
                  
                  $entityManager->merge($entity);
                  $entityManager->flush();
                  

                  这篇关于实施“如果存在则更新"在学说 ORM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 的问题)

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

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

                          • <bdo id='EcMRR'></bdo><ul id='EcMRR'></ul>
                              <tbody id='EcMRR'></tbody>