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

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

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

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

      帶有消息“SQLSTATE[22001]"的“PDOException":字

      #39;PDOException#39; with message #39;SQLSTATE[22001]: String data, right truncated: 0(帶有消息“SQLSTATE[22001]的“PDOException:字符串數據,右截斷:0)
      • <i id='CNEAl'><tr id='CNEAl'><dt id='CNEAl'><q id='CNEAl'><span id='CNEAl'><b id='CNEAl'><form id='CNEAl'><ins id='CNEAl'></ins><ul id='CNEAl'></ul><sub id='CNEAl'></sub></form><legend id='CNEAl'></legend><bdo id='CNEAl'><pre id='CNEAl'><center id='CNEAl'></center></pre></bdo></b><th id='CNEAl'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='CNEAl'><tfoot id='CNEAl'></tfoot><dl id='CNEAl'><fieldset id='CNEAl'></fieldset></dl></div>

          <tfoot id='CNEAl'></tfoot>
              <tbody id='CNEAl'></tbody>

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

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

                <bdo id='CNEAl'></bdo><ul id='CNEAl'></ul>
                本文介紹了帶有消息“SQLSTATE[22001]"的“PDOException":字符串數據,右截斷:0的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                注意:我已經將這個問題縮小到專門的 PDO,因為我能夠使用 odbc_* 函數.

                為什么我不能將此參數綁定到 PDO 準備好的語句?

                這有效:

                $mssqldriver = 'ODBC Driver 13 for SQL Server';$pdoDB = new PDO("odbc:Driver=$mssqldriver;Server=$hostname;Database=$dbname", $username, $password);$pdoDB->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );$sql = "SELECT 'value' AS col where 'this' = 'this'";$stmt = $pdoDB->prepare($sql);$params = [];$stmt->execute($params);print_r($stmt->fetch());

                <塊引用>

                Array ( [col] => value [0] => value )

                不起作用:

                $sql = "SELECT 'value' AS col where 'this' = ?";$stmt = $pdoDB->prepare($sql);$params = ['this'];$stmt->execute($params);print_r($stmt->fetch());

                Web Server 在 Linux Ubuntu 14.04 上運行 PHP 5.5.9,使用 ODBC Driver 13 for SQL Server 并連接到 Windows Server 2012 上的 Microsoft SQL Server 2012

                這是完整的錯誤:

                <塊引用>

                致命錯誤:未捕獲的異常PDOException",消息為SQLSTATE[22001]":字符串數據,右截斷:0[Microsoft][用于 SQL Server 的 ODBC 驅動程序 13]字符串數據,右截斷(SQLExecute[0] at/build/buildd/php5-5.5.9+dfsg/ext/pdo_odbc/odbc_stmt.c:254)' 在/var/www/scratch.php:46堆棧跟蹤:#0/var/www/scratch.php(46): PDOStatement->execute(Array)#1 {main} 在第 46 行的/var/www/scratch.php 中拋出

                我也試過設置:

                $pdoDB->setAttribute( PDO::ATTR_EMULATE_PREPARES, true );

                并使用命名參數:

                $sql = "SELECT 'value' AS col where 'this' = :myVal";$stmt = $pdoDB->prepare($sql);$params = ['myVal' =>'這'];$stmt->execute($params);print_r($stmt->fetch());

                即使有一個明確的冒號:

                $params = [':myVal' =>'這'];

                我也試過只使用 bindParam如這個答案所示:

                $sql = "SELECT 'value' AS col where 'this' = ?";$stmt = $pdoDB->prepare($sql);$param = '這個';$stmt->bindParam(1, $param);$stmt->execute();print_r($stmt->fetch());

                以及命名參數:

                $sql = "SELECT 'value' AS col where 'this' = :myVal";$stmt = $pdoDB->prepare($sql);$param = '這個';$stmt->bindParam(':myVal', $param, PDO::PARAM_STR);$stmt->execute();print_r($stmt->fetch());

                如果我嘗試明確設置長度:

                $stmt->bindParam(':myVal', $param, PDO::PARAM_STR, 4);

                我收到一個獎勵錯誤:

                <塊引用>

                致命錯誤:未捕獲的異常 'PDOException' 帶有消息'SQLSTATE[42000]:語法錯誤或訪問沖突:102[Microsoft][用于 SQL Server 的 ODBC 驅動程序 13][SQL Server]'OUTPUT' 附近的語法不正確.

                是的,所有這些都是一個沒有表格的簡單示例,因此您可以輕松重現它,但可以肯定的是,我實際上已經用真實的表格進行了嘗試.

                CREATE TABLE myTable (id INT 身份主鍵,val NVARCHAR(255));INSERT INTO myTable (val) VALUES ('hello world');

                作品:

                $sql = "SELECT * FROM myTable WHERE val = 'hello world'";$stmt = $pdoDB->prepare($sql);$params = [];$stmt->execute($params);print_r($stmt->fetch());

                <塊引用>

                Array ( [id] => 1 [0] => 1 [val] => hello world [1] => hello world )

                不起作用:

                $sql = "SELECT * FROM myTable WHERE val = ?";$stmt = $pdoDB->prepare($sql);$params = ['你好世界'];$stmt->execute($params);print_r($stmt->fetch());

                所有路徑都導致相同的錯誤:

                <塊引用>

                字符串數據,右截斷

                解決方案

                很遺憾,

                這是一個 PDO_ODBC 64 位不兼容問題(#61777、#64824) 并且毫無疑問你是 64-bit build 不允許你綁定參數.

                幸運的是,

                它有一個補丁首次包含在 5.6 版本中:

                <塊引用>

                這個bug也參考了#61777 并且仍然存在在 5.5 分支的最新穩定版本中.我看到兩張票這個問題已經存在,我只是提交這些更改通過 github 作為提醒,這對任何人來說都是一個嚴重的問題在 x64 版本上使用 PDO_ODBC.

                您的 PHP 附帶的 PDO_ODBC 有什么問題?

                通過查看推薦的補丁之一:

                diff --git a/ext/pdo_odbc/odbc_stmt.c b/ext/pdo_odbc/odbc_stmt.c索引 8b0ccf3..1d275cd 100644--- a/ext/pdo_odbc/odbc_stmt.c+++ b/ext/pdo_odbc/odbc_stmt.c@@ -551,7 +551,7 @@ static int odbc_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC)struct pdo_column_data *col = &stmt->columns[colno];RETCODE rc;劍柱;- SDWORD colsize;+ SQLULEN colsize;SQLLEN 顯示大小;

                我們看到唯一改變的是 SDWORD(16 位有符號整數),它被替換為新的 ODBC 類型 SQLULEN,即 64 位 ODBC 應用程序中的 64 位和 32 位 ODBC 應用程序中的 32 位.

                我相信提交者不知道 colsize 數據類型只是因為在下一行 SQLLEN 被正確定義.

                我現在該怎么辦?

                1. 升級到 PHP 版本 >= 5.6
                2. 堅持使用 odbc_* 函數作為可行的解決方案.
                3. 使用提供的補丁編譯 PHP v5.5.9.
                4. 按照@GordonM 的建議構建您自己的 PDO 包裝器

                NOTE: I have narrowed this problem down to specifically PDO because I am able to successfully prepare and execute statements using the odbc_* functions.

                Why can't I bind this parameter to the PDO prepared statement?

                This works:

                $mssqldriver = 'ODBC Driver 13 for SQL Server';
                $pdoDB = new PDO("odbc:Driver=$mssqldriver;Server=$hostname;Database=$dbname", $username, $password);
                $pdoDB->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
                
                $sql = "SELECT 'value' AS col where 'this' = 'this'";
                $stmt = $pdoDB->prepare($sql);
                $params = [];
                $stmt->execute($params);
                print_r($stmt->fetch());
                

                Array ( [col] => value [0] => value )
                

                Does not work:

                $sql = "SELECT 'value' AS col where 'this' = ?";
                $stmt = $pdoDB->prepare($sql);
                $params = ['this'];
                $stmt->execute($params);
                print_r($stmt->fetch());
                

                Web Server is running PHP 5.5.9 on Linux Ubuntu 14.04 with ODBC Driver 13 for SQL Server and connecting to Microsoft SQL Server 2012 on Windows Server 2012

                Here's the full error:

                Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[22001]:
                String data, right truncated: 0
                [Microsoft][ODBC Driver 13 for SQL Server]
                String data, right truncation
                (SQLExecute[0] at /build/buildd/php5-5.5.9+dfsg/ext/pdo_odbc/odbc_stmt.c:254)' in /var/www/scratch.php:46
                Stack trace:
                #0 /var/www/scratch.php(46): PDOStatement->execute(Array)
                #1 {main} thrown in /var/www/scratch.php on line 46
                

                I have also tried setting:

                $pdoDB->setAttribute( PDO::ATTR_EMULATE_PREPARES, true );
                

                And using named parameters:

                $sql = "SELECT 'value' AS col where 'this' = :myVal";
                $stmt = $pdoDB->prepare($sql);
                $params = ['myVal' => 'this'];
                $stmt->execute($params);
                print_r($stmt->fetch());
                

                Even with an explicit colon:

                $params = [':myVal' => 'this'];
                

                I also tried just using bindParam as demonstrated in this answer:

                $sql = "SELECT 'value' AS col where 'this' = ?";
                $stmt = $pdoDB->prepare($sql);
                $param = 'this';
                $stmt->bindParam(1, $param);
                $stmt->execute();
                print_r($stmt->fetch());
                

                As well as with named parameters:

                $sql = "SELECT 'value' AS col where 'this' = :myVal";
                $stmt = $pdoDB->prepare($sql);
                $param = 'this';
                $stmt->bindParam(':myVal', $param, PDO::PARAM_STR);
                $stmt->execute();
                print_r($stmt->fetch());
                

                If I try to explicitly set the length:

                $stmt->bindParam(':myVal', $param, PDO::PARAM_STR, 4);
                

                I get a bonus error:

                Fatal error: Uncaught exception 'PDOException' with message
                'SQLSTATE[42000]: Syntax error or access violation: 102
                [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]
                Incorrect syntax near 'OUTPUT'.
                

                And yes, all this is a trivialized example without tables so that you can easily reproduce it, but just to be sure, I have actually tried this with a real table.

                CREATE TABLE myTable (
                    id INT IDENTITY PRIMARY KEY,
                    val NVARCHAR(255)
                );
                INSERT INTO myTable (val) VALUES ('hello world');
                

                Works:

                $sql = "SELECT * FROM myTable WHERE val = 'hello world'";
                $stmt = $pdoDB->prepare($sql);
                $params = [];
                $stmt->execute($params);
                print_r($stmt->fetch());
                

                Array ( [id] => 1 [0] => 1 [val] => hello world [1] => hello world )
                

                Does not work:

                $sql = "SELECT * FROM myTable WHERE val = ?";
                $stmt = $pdoDB->prepare($sql);
                $params = ['hello world'];
                $stmt->execute($params);
                print_r($stmt->fetch());
                

                All paths lead to the same error:

                String data, right truncated

                解決方案

                Unfortunately,

                It's a PDO_ODBC 64-bit incompatibility problem (#61777, #64824) and without any doubts you are on a 64-bit build which doesn't allow you to bind parameters.

                Fortunately,

                It has a patch that was first included in the 5.6 release:

                This bug is also referenced in #61777 and is still present in the latest stable release of the 5.5 branch. I see two tickets exist for this problem already, and I'm just submitting these changes via github as a reminder that this is a serious problem for anyone using PDO_ODBC on the x64 builds.

                What is wrong with your PHP's shipped PDO_ODBC?

                By looking at one of those recommended patches:

                diff --git a/ext/pdo_odbc/odbc_stmt.c b/ext/pdo_odbc/odbc_stmt.c
                index 8b0ccf3..1d275cd 100644
                --- a/ext/pdo_odbc/odbc_stmt.c
                +++ b/ext/pdo_odbc/odbc_stmt.c
                @@ -551,7 +551,7 @@ static int odbc_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC)
                    struct pdo_column_data *col = &stmt->columns[colno];
                    RETCODE rc;
                    SWORD   colnamelen;
                -   SDWORD  colsize;
                +   SQLULEN colsize;
                    SQLLEN displaysize;
                

                We see the only thing that's changed is SDWORD (16-bit signed integer) which is substituted with new ODBC type SQLULEN that is 64 bits in a 64-bit ODBC application and 32 bits in a 32-bit ODBC application.

                I believe committer wasn't aware of colsize data type only since in the very next line SQLLEN is defined properly.

                What should I do now?

                1. Upgrade to PHP version >= 5.6
                2. Stick with odbc_* functions as a working solution.
                3. Compile a PHP v5.5.9 with provided patches.
                4. Build your own PDO wrapper as recommended by @GordonM

                這篇關于帶有消息“SQLSTATE[22001]"的“PDOException":字符串數據,右截斷:0的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                相關文檔推薦

                MySQLi prepared statement amp; foreach loop(MySQLi準備好的語句amp;foreach 循環)
                Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是從整個服務器還是從同一用戶獲取記錄?)
                PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 無法識別登錄信息)
                mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 個參數)
                Php mysql pdo query: fill up variable with query result(Php mysql pdo 查詢:用查詢結果填充變量)
                MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用戶“root@“localhost的訪問被拒絕)
                  <tbody id='yqF9o'></tbody>

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

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

                        1. 主站蜘蛛池模板: 精品一区二区三区中文字幕 | 久久免费精品 | 国产无人区一区二区三区 | 国产精品免费一区二区三区四区 | 欧美精品乱码久久久久久按摩 | 最新国产福利在线 | 在线免费看黄 | 免费观看羞羞视频网站 | 欧美日韩亚洲视频 | 成人福利在线观看 | 激情av在线| 午夜视频一区二区 | 91久久精品国产91久久性色tv | 国产玖玖| 国产在线一区二区 | 视频一区在线 | 91精品国产综合久久久久久漫画 | 国产亚洲成av人在线观看导航 | 蜜桃av一区二区三区 | 欧美不卡一区二区三区 | 国产精品一区二区不卡 | 一级黄色录像毛片 | 天堂色| 九九亚洲| 日日干日日射 | 成人在线视频免费观看 | 国产欧美日韩在线播放 | 成人久久18免费网站 | 日本精品一区二区三区在线观看视频 | 久久久久久九九九九九九 | 久久精品91久久久久久再现 | 成人在线看片 | 日韩在线看片 | 成人精品高清 | 久久国产免费看 | 国产一区二区三区在线看 | 精品日韩一区二区 | 中文字幕亚洲区一区二 | 妞干网福利视频 | 国产乡下妇女做爰 | 久久精品成人 |