<legend id='kaWpM'><style id='kaWpM'><dir id='kaWpM'><q id='kaWpM'></q></dir></style></legend>
  1. <tfoot id='kaWpM'></tfoot>
      <bdo id='kaWpM'></bdo><ul id='kaWpM'></ul>

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

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

      从带有 PDO 的 SELECT 中插入 MySQL

      时间:2023-10-30

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

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

            <bdo id='kR13e'></bdo><ul id='kR13e'></ul>
              <tfoot id='kR13e'></tfoot>
            • <i id='kR13e'><tr id='kR13e'><dt id='kR13e'><q id='kR13e'><span id='kR13e'><b id='kR13e'><form id='kR13e'><ins id='kR13e'></ins><ul id='kR13e'></ul><sub id='kR13e'></sub></form><legend id='kR13e'></legend><bdo id='kR13e'><pre id='kR13e'><center id='kR13e'></center></pre></bdo></b><th id='kR13e'></th></span></q></dt></tr></i><div id='kR13e'><tfoot id='kR13e'></tfoot><dl id='kR13e'><fieldset id='kR13e'></fieldset></dl></div>
                  <tbody id='kR13e'></tbody>
                本文介绍了从带有 PDO 的 SELECT 中插入 MySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                I have a strange behaviour using PHP PDO for a INSERT from a SELECT query. Testing the query directly in MySQL it works well, I get my row inserted :

                INSERT INTO sessionid (enc_id, enc_pass, enc_date) 
                SELECT AES_ENCRYPT(username, 'aeskey'), AES_ENCRYPT(pwd, 'aeskey'), 
                DATE_ADD(NOW(), INTERVAL 15 SECOND) FROM users WHERE username = 'a_user_name';
                

                But using PDO, I have one row per user inserted at once (279 rows) .... Here is the PHP :

                $sql_enc = '
                    INSERT INTO sessionid (enc_id, enc_pass, enc_date) 
                        (SELECT AES_ENCRYPT(username, :aeskey), AES_ENCRYPT(pwd, :aeskey), DATE_ADD(NOW(), INTERVAL 15 SECOND) FROM users WHERE username = :username)
                ';
                $res_enc = $pdo->prepare($sql_enc);
                $res_enc->bindParam(':aeskey', $aeskey);
                $res_enc->bindParam(':username', $username);
                $res_enc->bindParam(':pwd', $username);
                $res_enc->execute();
                $res_enc = null;
                

                What am I missing? I'm almost sure it's nothing but can't make it insert that single row.

                Thank you.

                fabien.

                解决方案

                Not that it is the probable problem, but you put a username in the password field in your code. In your query you insert the aeskey there. It is the only difference I can spot.

                这篇关于从带有 PDO 的 SELECT 中插入 MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何获取我刚刚插入 php/mysql 的行的 id 下一篇:php mysql 插入 utf-8

                相关文章

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