pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    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="ssu2ew2" 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:字符串數(shù)據,右截斷: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="0eysqmm" 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":字符串數(shù)據,右截斷:0的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

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

                為什么我不能將此參數(shù)綁定到 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]":字符串數(shù)據,右截斷:0[Microsoft][用于 SQL Server 的 ODBC 驅動程序 13]字符串數(shù)據,右截斷(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 );

                并使用命名參數(shù):

                $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());

                以及命名參數(shù):

                $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' 附近的語法不正確.

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

                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());

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

                <塊引用>

                字符串數(shù)據,右截斷

                解決方案

                很遺憾,

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

                幸運的是,

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

                <塊引用>

                這個bug也參考了#61777 并且仍然存在在 5.5 分支的最新穩(wěn)定版本中.我看到兩張票這個問題已經存在,我只是提交這些更改通過 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 位有符號整數(shù)),它被替換為新的 ODBC 類型 SQLULEN,即 64 位 ODBC 應用程序中的 64 位和 32 位 ODBC 應用程序中的 32 位.

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

                我現(xiàn)在該怎么辦?

                1. 升級到 PHP 版本 >= 5.6
                2. 堅持使用 odbc_* 函數(shù)作為可行的解決方案.
                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":字符串數(shù)據,右截斷:0的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                相關文檔推薦

                MySQLi prepared statement amp; foreach loop(MySQLi準備好的語句amp;foreach 循環(huán))
                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 個參數(shù))
                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@“l(fā)ocalhost的訪問被拒絕)
                  <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="ogkguuc" id='yqF9o'><tfoot id='yqF9o'></tfoot><dl id='yqF9o'><fieldset id='yqF9o'></fieldset></dl></div>

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

                        1. 主站蜘蛛池模板: 讲师宝经纪-专业培训机构师资供应商_培训机构找讲师、培训师、讲师经纪就上讲师宝经纪 | Akribis直线电机_直线模组_力矩电机_直线电机平台|雅科贝思Akribis-杭州摩森机电科技有限公司 | 变频器维修公司_plc维修_伺服驱动器维修_工控机维修 - 夫唯科技 变位机,焊接变位机,焊接变位器,小型变位机,小型焊接变位机-济南上弘机电设备有限公司 | 烟雾净化器-滤筒除尘器-防爆除尘器-除尘器厂家-东莞执信环保科技有限公司 | 全自动真空上料机_粉末真空上料机_气动真空上料机-南京奥威环保科技设备有限公司 | vr安全体验馆|交通安全|工地安全|禁毒|消防|安全教育体验馆|安全体验教室-贝森德(深圳)科技 | 双齿辊破碎机-大型狼牙破碎机视频-对辊破碎机价格/型号图片-金联机械设备生产厂家 | 铜镍-康铜-锰铜-电阻合金-NC003 - 杭州兴宇合金有限公司 | 环氧乙烷灭菌器_压力蒸汽灭菌器_低温等离子过氧化氢灭菌器 _低温蒸汽甲醛灭菌器_清洗工作站_医用干燥柜_灭菌耗材-环氧乙烷灭菌器_脉动真空压力蒸汽灭菌器_低温等离子灭菌设备_河南省三强医疗器械有限责任公司 | 陕西视频监控,智能安防监控,安防系统-西安鑫安5A安防工程公司 | 高低温试验房-深圳高低温湿热箱-小型高低温冲击试验箱-爱佩试验设备 | 中细软知识产权_专业知识产权解决方案提供商| elisa试剂盒价格-酶联免疫试剂盒-猪elisa试剂盒-上海恒远生物科技有限公司 | 山东成考网-山东成人高考网 | 氧化铁红厂家-淄博宗昂化工 | 上海网站建设-上海网站制作-上海网站设计-上海做网站公司-咏熠软件 | 西门子伺服控制器维修-伺服驱动放大器-828D数控机床维修-上海涌迪 | 玉米深加工机械,玉米加工设备,玉米加工机械等玉米深加工设备制造商-河南成立粮油机械有限公司 | PCB厂|线路板厂|深圳线路板厂|软硬结合板厂|电路板生产厂家|线路板|深圳电路板厂家|铝基板厂家|深联电路-专业生产PCB研发制造 | 博客-悦享汽车品质生活 | 搅拌磨|搅拌球磨机|循环磨|循环球磨机-无锡市少宏粉体科技有限公司 | 亚洲工业智能制造领域专业门户网站 - 亚洲自动化与机器人网 | 深圳标识制作公司-标识标牌厂家-深圳广告标识制作-玟璟广告-深圳市玟璟广告有限公司 | 对夹式止回阀厂家,温州对夹式止回阀制造商--永嘉县润丰阀门有限公司 | 检验科改造施工_DSA手术室净化_导管室装修_成都特殊科室建设厂家_医疗净化工程公司_四川华锐 | MOOG伺服阀维修,ATOS比例流量阀维修,伺服阀维修-上海纽顿液压设备有限公司 | 聚氨酯复合板保温板厂家_廊坊华宇创新科技有限公司 | 送料机_高速冲床送料机_NC伺服滚轮送料机厂家-东莞市久谐自动化设备有限公司 | 电动高尔夫球车|电动观光车|电动巡逻车|电动越野车厂家-绿友机械集团股份有限公司 | 电机铸铝配件_汽车压铸铝合金件_发动机压铸件_青岛颖圣赫机械有限公司 | 上海瑶恒实业有限公司|消防泵泵|离心泵|官网 | 挤奶设备过滤纸,牛奶过滤纸,挤奶机过滤袋-济南蓝贝尔工贸有限公司 | 物和码官网,物和码,免费一物一码数字化营销SaaS平台 | 气动机械手-搬运机械手-气动助力机械手-山东精瑞自动化设备有限公司 | 考勤系统_人事考勤管理系统_本地部署BS考勤系统_考勤软件_天时考勤管理专家 | 奥因-光触媒除甲醛公司-除甲醛加盟公司十大品牌 | 冰晶石|碱性嫩黄闪蒸干燥机-有机垃圾烘干设备-草酸钙盘式干燥机-常州市宝康干燥 | 广东泵阀展|阀门展-广东国际泵管阀展览会 | 拉力机-万能试验机-材料拉伸试验机-电子拉力机-拉力试验机厂家-冲击试验机-苏州皖仪实验仪器有限公司 | 企小优-企业数字化转型服务商_网络推广_网络推广公司 | 钢格板|镀锌钢格板|热镀锌钢格板|格栅板|钢格板|钢格栅板|热浸锌钢格板|平台钢格板|镀锌钢格栅板|热镀锌钢格栅板|平台钢格栅板|不锈钢钢格栅板 - 专业钢格板厂家 |