• <bdo id='ALq0k'></bdo><ul id='ALq0k'></ul>

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

      1. <small id='ALq0k'></small><noframes id='ALq0k'>

        <tfoot id='ALq0k'></tfoot>

        Doctrine - 如何在 postSave() 事件中获取 SQL INSERT 查询?

        Doctrine - how to get the SQL INSERT query, in the postSave() event?(Doctrine - 如何在 postSave() 事件中获取 SQL INSERT 查询?)
        <tfoot id='uZ4H2'></tfoot>
            <bdo id='uZ4H2'></bdo><ul id='uZ4H2'></ul>
            <i id='uZ4H2'><tr id='uZ4H2'><dt id='uZ4H2'><q id='uZ4H2'><span id='uZ4H2'><b id='uZ4H2'><form id='uZ4H2'><ins id='uZ4H2'></ins><ul id='uZ4H2'></ul><sub id='uZ4H2'></sub></form><legend id='uZ4H2'></legend><bdo id='uZ4H2'><pre id='uZ4H2'><center id='uZ4H2'></center></pre></bdo></b><th id='uZ4H2'></th></span></q></dt></tr></i><div id='uZ4H2'><tfoot id='uZ4H2'></tfoot><dl id='uZ4H2'><fieldset id='uZ4H2'></fieldset></dl></div>
            <legend id='uZ4H2'><style id='uZ4H2'><dir id='uZ4H2'><q id='uZ4H2'></q></dir></style></legend>
              1. <small id='uZ4H2'></small><noframes id='uZ4H2'>

                  <tbody id='uZ4H2'></tbody>

                  本文介绍了Doctrine - 如何在 postSave() 事件中获取 SQL INSERT 查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想获得在调用对象的 save() 方法时 Doctrine 生成的确切 SQL INSERT 查询.

                  I would like to get the exact SQL INSERT query that Doctrine generates when an object's save() method is called.

                  最好是在模型的 postSave() 事件中获取,并记录到 txt 文件中.

                  Preferably, I would like to get it in the postSave() event of the model and log it in a txt file.

                  例如:

                  <?php 
                  $user = new User(); // A Doctrine Model with timestampable behavior enabled
                  $user->first_name = 'Manny';
                  $user->last_name = 'Calavera';
                  $user->save();
                  ?>
                  

                  我想获取/记录以下 SQL 查询:

                  I want to get/log the following SQL query:

                  INSERT INTO user (first_name, last_name, created_at, updated_at) VALUES ('Manny', 'Calavera', '2010-08-03 12:00:00', '2010-08-03 12:00:00');
                  

                  需要这个的背景是我希望稍后通过解析txt文件来批量导入数据.

                  The background for needing this, is that I wish to mass-import later the data by parsing the txt file.

                  推荐答案

                  我不认为有任何简单的方法可以做到这一点,因为 save() 的行为取决于一些不同的事情(如果你正在插入/更新).

                  I don't think there is any easy way to do this since the behaviour of save() varies depending on a few different things (if you're inserting/updating).

                  如果您已经创建了一个学说查询对象,那么您可以像这样调用 getSqlQuery() 方法:

                  If you had created a doctrine query object, then you can call the getSqlQuery() method like this:

                  $q = Doctrine_Query::create()
                  ->select('u.id')
                  ->from('User u');
                  
                  echo $q->getSqlQuery();
                  

                  但是 save() 是一个方法,而不是一个对象,所以这不起作用.我认为您必须编写一些代码来检测您是在插入还是更新并构建查询以即时登录,然后使用 save().

                  but the save() is a method, not an object so this won't work. I think you'll have to hack in some code to detect whether you're inserting or updating and build a query to log on the fly and then use save().

                  我知道这个建议并不理想,因为它没有准确"记录 save() 正在做什么,但出于您所说的目的,它应该仍然可以正常工作.

                  I know this suggestion is not ideal because it is not logging 'exactly' what save() is doing but for the purposes you stated it should still work just as well.

                  这篇关于Doctrine - 如何在 postSave() 事件中获取 SQL INSERT 查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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='DRhcn'></small><noframes id='DRhcn'>

                      <legend id='DRhcn'><style id='DRhcn'><dir id='DRhcn'><q id='DRhcn'></q></dir></style></legend>
                        <tbody id='DRhcn'></tbody>

                      • <bdo id='DRhcn'></bdo><ul id='DRhcn'></ul>

                        • <tfoot id='DRhcn'></tfoot>

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