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

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

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

      PDO 在 PHP5.4 中以字符串形式返回整數列

      PDO returns integer columns as String in PHP5.4(PDO 在 PHP5.4 中以字符串形式返回整數列)

        <tbody id='eav1m'></tbody>

      <tfoot id='eav1m'></tfoot>

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

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

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

                <bdo id='eav1m'></bdo><ul id='eav1m'></ul>
              • 本文介紹了PDO 在 PHP5.4 中以字符串形式返回整數列的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                首先,我知道關于 SO 有各種類似的問題,例如 this 和 這個.但是,當我從表中獲取值時,整數總是作為字符串獲取.

                First of all, I am aware that there are various similar questions on SO such as this and this. However, when I fetch values from a table, integers are always fetched as string.

                我使用的是 PHP5.4 (5.4.16-1~dotdeb.1) 和 MYSQL5.5 (5.5.31+dfsg-0+wheezy1).這里 寫到 PHP5 默認啟用 MySQL Native Driver.4.0.但我仍然得到字符串值.

                I am using PHP5.4 (5.4.16-1~dotdeb.1) and MYSQL5.5 (5.5.31+dfsg-0+wheezy1). It is written here that MySQL Native Driver is enabled by default in PHP5.4.0. But I still get string values.

                我按如下方式初始化一個 PDO 對象.

                I initialize a PDO object as follows.

                try {
                        $dsn = 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME . ';charset=utf8';
                
                        $db = new PDO($dsn,DB_USER,DB_PASS);
                
                        $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
                
                        $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
                    } catch (PDOException $e) {
                        header('HTTP/1.1 500');
                        exit;
                    } catch (Exception $e) {
                        header('HTTP/1.1 500');
                        exit;
                    }
                

                當我插入時,我嘗試使用 execute(array(...)) 格式并且還使用了 bindValue(...,PDO::PARAM_INT),但它們沒有任何區別.

                When I insert, I tried to use execute(array(...)) format and also used bindValue(...,PDO::PARAM_INT), but they did not make a difference.

                例如,這是我插入新行的方法.

                For example, here is how I insert a new row.

                public function insertList ($db,$account_id,$list_name) {
                    $sql = $db->prepare('INSERT INTO lists VALUES (?,?,?,?,?)');
                
                    try {
                        // $sql->execute(array($list_name,0,0,0,$account_id));
                
                        $sql->bindValue(1,$list_name,PDO::PARAM_STR);
                        $sql->bindValue(2,0,PDO::PARAM_INT);
                        $sql->bindValue(3,0,PDO::PARAM_INT);
                        $sql->bindValue(4,0,PDO::PARAM_INT);
                        $sql->bindValue(5,$account_id,PDO::PARAM_INT);
                        $sql->execute();
                    } catch (PDOException $e) {
                        header('HTTP/1.1 500');
                        exit;
                    } catch (Exception $e) {
                        header('HTTP/1.1 500');
                        exit;
                    }
                }
                

                這是我如何從表中獲取行

                Here is how I fetch rows from a table

                public function fetchLists ($db,$account_id) {
                    $sql = $db->prepare('SELECT * FROM lists WHERE account_id=?');
                
                    try {
                        $sql->execute(array($account_id));
                
                        $result = $sql->fetchAll(PDO::FETCH_ASSOC);
                    } catch (PDOException $e) {
                        header('HTTP/1.1 500');
                        exit;
                    } catch (Exception $e) {
                        header('HTTP/1.1 500');
                        exit;
                    }
                
                    return $result;
                }
                

                當我在使用 PHP5.4.7 的 XAMPP for Linux 1.8.1 上測試時沒有發生這種情況.我目前使用 nginx 而不是 Apache.

                This did not occur when I tested on XAMPP for Linux 1.8.1 which uses PHP5.4.7. I currently use nginx instead of Apache.

                怎么了?

                推薦答案

                要從帶有 PDO 的 mysql 獲取具有各自類型的整數和浮點數,您需要同時關閉基于 mysqlnd 的 PDO-mysql 和仿真模式.

                To get integers and floats with respective types from mysql with PDO, you need both mysqlnd-based PDO-mysql and emulation mode turned off.

                這篇關于PDO 在 PHP5.4 中以字符串形式返回整數列的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                相關文檔推薦

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

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

                    <tbody id='cwkic'></tbody>

                    <i id='cwkic'><tr id='cwkic'><dt id='cwkic'><q id='cwkic'><span id='cwkic'><b id='cwkic'><form id='cwkic'><ins id='cwkic'></ins><ul id='cwkic'></ul><sub id='cwkic'></sub></form><legend id='cwkic'></legend><bdo id='cwkic'><pre id='cwkic'><center id='cwkic'></center></pre></bdo></b><th id='cwkic'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='cwkic'><tfoot id='cwkic'></tfoot><dl id='cwkic'><fieldset id='cwkic'></fieldset></dl></div>
                        <bdo id='cwkic'></bdo><ul id='cwkic'></ul>
                          主站蜘蛛池模板: 亚洲毛片一区二区 | 成人国产精品免费观看视频 | av在线免费观看网址 | 免费视频一区二区 | 国产精品夜夜夜一区二区三区尤 | 亚洲国产精品一区二区久久 | 国产精品一区二区免费 | www.狠狠干 | 中文字幕99 | 成人免费影院 | 久久久久国产成人精品亚洲午夜 | 免费一区 | 精品久久久久久亚洲综合网 | 操网站 | 亚洲一二三区在线观看 | 一区二区三区免费 | 在线成人免费视频 | 无码一区二区三区视频 | 91精品国产综合久久婷婷香蕉 | 久久99精品久久久久 | 男人天堂99 | 久久黄色精品视频 | 国产日韩一区二区 | 3级毛片 | 中文字幕日韩av | 国产精品久久毛片av大全日韩 | 伊人春色在线 | 国产欧美精品一区二区 | 国产在线视频一区二区 | 国产高清一区二区三区 | 欧美亚洲视频 | gav成人免费播放视频 | 久久久精品一区 | 国产精品久久久久久久久久三级 | 国产精品视频一二三区 | 国产小u女发育末成年 | 在线男人天堂 | 中文字幕亚洲一区 | 久久最新精品 | 日韩中文字幕在线免费 | 日本国产精品视频 |