久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

<tfoot id='BGyda'></tfoot>

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

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

      不能使用整數(shù)值多次執(zhí)行準(zhǔn)備好的語句

      Prepared statement cannot be executed multiple times with integer values(不能使用整數(shù)值多次執(zhí)行準(zhǔn)備好的語句)

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

        <tbody id='sEYbR'></tbody>

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

                本文介紹了不能使用整數(shù)值多次執(zhí)行準(zhǔn)備好的語句的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                如何使用不同的整數(shù)值正確地重新執(zhí)行準(zhǔn)備好的語句?

                How do I properly re-execute a prepared statement using different integer values?

                重用 ODBC 準(zhǔn)備好的語句時,顯式和隱式綁定 PDO::PARAM_INT 存在致命錯誤.

                There's something deathly wrong with explicit and implicit binding PDO::PARAM_INT when reusing an ODBC prepared statement.

                CREATE TABLE mytab (
                    col INT,
                    something VARCHAR(20)
                );
                

                作品:多個字符串

                $pdoDB = new PDO('odbc:Driver=ODBC Driver 13 for SQL Server;
                  Server='.DATABASE_SERVER.';
                  Database='.DATABASE_NAME,
                  DATABASE_USERNAME,
                  DATABASE_PASSWORD
                );
                $pdoDB->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
                
                $values = ['here','are','some','values'];
                $sql = "INSERT INTO mytab (something) VALUES (:something)";
                $stmt = $pdoDB->prepare($sql);
                foreach ($values as $value)
                  $stmt->execute(['something'=>$value]);
                

                作品:單個整數(shù)

                $values = [42];
                $sql = "INSERT INTO mytab (col) VALUES (:col)";
                $stmt = $pdoDB->prepare($sql);
                foreach ($values as $value)
                  $stmt->execute(['col'=>$value]);
                

                不起作用:多個整數(shù)

                $values = [1,3,5,7,11];
                $sql = "INSERT INTO mytab (col) VALUES (:col)";
                $stmt = $pdoDB->prepare($sql);
                foreach ($values as $value)
                  $stmt->execute(['col'=>$value]);
                

                它實(shí)際上成功地插入了第一條記錄1,但是當(dāng)它嘗試在下一次執(zhí)行時重用該語句時失敗了.

                It actually successfully inserts the first record 1 but fails when it tries to reuse the statement on the next execute.

                PHP 致命錯誤:未捕獲的 PDOException:SQLSTATE[22018]:轉(zhuǎn)換規(guī)范的字符值無效:206 [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]操作數(shù)類型沖突:文本與 int 不兼容(SQLExecute[206] 在/build/php7.0-lPMnpS/php7.0-7.0.8/ext/pdo_odbc/odbc_stmt.c:260)

                PHP Fatal error: Uncaught PDOException: SQLSTATE[22018]: Invalid character value for cast specification: 206 [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Operand type clash: text is incompatible with int (SQLExecute[206] at /build/php7.0-lPMnpS/php7.0-7.0.8/ext/pdo_odbc/odbc_stmt.c:260)

                我使用 適用于 SQL Server? 的 Microsoft? ODBC 驅(qū)動程序 13(預(yù)覽版)

                我已經(jīng)嘗試將整個事情包裝在 PDO::beginTransactionPDO::commit

                I have tried wrapping the whole thing in PDO::beginTransaction and PDO::commit

                我也試過使用 PDOStatement::bindParam 但它拋出完全相同的錯誤.

                I've also tried using PDOStatement::bindParam but it throws the exact same error.

                $values = [1];
                $sql = "INSERT INTO mytab (col) VALUES (:col)";
                $stmt = $pdoDB->prepare($sql);
                foreach ($values as $value){
                  $stmt->bindParam('col', $value, PDO::PARAM_INT);
                  $stmt->execute();
                }
                

                不起作用

                $values = [1,2];
                $sql = "INSERT INTO mytab (col) VALUES (:col)";
                $stmt = $pdoDB->prepare($sql);
                foreach ($values as $value){
                  $stmt->bindParam('col', $value, PDO::PARAM_INT);
                  $stmt->execute();
                }
                

                我認(rèn)為有趣的是,我在使用 PHP 5.6.9 時遇到了與此未回答的問題完全相同的錯誤.但是,他們甚至無法執(zhí)行一個語句,所以我想知道是否有部分補(bǔ)丁考慮到拋出錯誤的確切行已從 odbc_stmt.c:254odbc_stmt.c:260

                I think it's interesting to note that I am getting the exact same error as this unanswered question using PHP 5.6.9. However, they are not able to execute even one statement, so I'm wondering if there's been a partial patch considering the exact line throwing the error has moved from odbc_stmt.c:254 to odbc_stmt.c:260

                如果我在循環(huán)中內(nèi)部準(zhǔn)備語句,那么它工作得很好.但我讀到這是非常低效的,我應(yīng)該能夠重用陳述.我特別擔(dān)心在大量數(shù)據(jù)集上使用它.這個可以嗎?有什么我可以做的更好的事情嗎?

                If I prepare the statement inside the loop, then it works just fine. But I've read that this is very inefficient and I should be able to reuse the statement. I'm particularly worried about using this with massive datasets. Is this OK? Is there something better that I can do?

                $values = [1,3,5,7,9,11];
                $sql = "INSERT INTO mytab (col) VALUES (:col)";
                foreach ($values as $value){
                  $stmt = $pdoDB->prepare($sql);
                  $stmt->execute(['col'=>$value]);
                }
                

                推薦答案

                在準(zhǔn)備好的語句的情況下,您通常必須在循環(huán)外使用 bindParam.

                In case of prepared statements you have to use bindParam outside of loop, usually.

                1. bindParam 是單步
                2. 設(shè)置綁定變量是一個可重復(fù)的步驟(循環(huán))
                3. 你必須為每次重復(fù)運(yùn)行execute

                我想,這樣的事情會奏效:

                I guess, something like that would work:

                $stmt = $pdoDB->prepare("INSERT INTO mytab (col, key) VALUES (:col, :key)");
                
                // bind params (by reference)
                $stmt->bindParams(":col", $col, PDO::PARAM_STR); //bind variable $col
                $stmt->bindParams(":key", $key, PDO::PARAM_INT); //bind variable $key
                
                $values = ['here','are','some','values'];
                foreach ($values as $i => $value) {
                    $col = $value; //set col
                    $key = $i; //set key
                    $stmt->execute();
                }
                

                這篇關(guān)于不能使用整數(shù)值多次執(zhí)行準(zhǔn)備好的語句的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                相關(guān)文檔推薦

                Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標(biāo)不起作用)
                PHP PDO ODBC connection(PHP PDO ODBC 連接)
                Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術(shù)方法)
                php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                MSSQL PDO could not find driver(MSSQL PDO 找不到驅(qū)動程序)
                  <tbody id='XkHaT'></tbody>
                • <bdo id='XkHaT'></bdo><ul id='XkHaT'></ul>

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

                    <legend id='XkHaT'><style id='XkHaT'><dir id='XkHaT'><q id='XkHaT'></q></dir></style></legend>
                    <tfoot id='XkHaT'></tfoot>

                      • <small id='XkHaT'></small><noframes id='XkHaT'>

                        • 主站蜘蛛池模板: 中文字幕在线精品 | 久久精品免费一区二区三 | 日韩免费福利视频 | 国产成人99久久亚洲综合精品 | 久久r精品| 国产一区二区久久 | 国产亚洲一区二区在线观看 | 精品国产乱码久久久久久1区2区 | 国产精品久久久久久久久久久免费看 | av午夜激情 | 日本一本在线 | 女人精96xxx免费网站p | 国产精品成av人在线视午夜片 | 亚洲一级视频在线 | av中文字幕网 | 精品国产免费一区二区三区演员表 | 九九九国产 | 成人三级视频在线观看 | 99免费| 国产在线观看一区二区三区 | 全免费a级毛片免费看视频免费下 | 成人国产精品免费观看 | 日本免费黄色 | 伊人久久精品 | 男女视频91| 深夜福利亚洲 | 97精品国产 | 国产精品黄 | 91国内外精品自在线播放 | 亚洲视频在线观看一区二区三区 | 91一区二区三区 | 午夜视频在线免费观看 | 欧美亚洲综合久久 | 国产亚洲日本精品 | 久久国产日本 | 日本激情视频中文字幕 | 亚洲国产一区视频 | 天天成人综合网 | 色吧久久| 国产日批| 亚洲一区二区黄 |