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

    <bdo id='4dThK'></bdo><ul id='4dThK'></ul>

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

    1. <legend id='4dThK'><style id='4dThK'><dir id='4dThK'><q id='4dThK'></q></dir></style></legend>
    2. <small id='4dThK'></small><noframes id='4dThK'>

    3. <tfoot id='4dThK'></tfoot>

      擴展 mysqli_result

      Extend mysqli_result(擴展 mysqli_result)

              <tbody id='tcRu0'></tbody>

          1. <tfoot id='tcRu0'></tfoot>
          2. <legend id='tcRu0'><style id='tcRu0'><dir id='tcRu0'><q id='tcRu0'></q></dir></style></legend>

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

            <i id='tcRu0'><tr id='tcRu0'><dt id='tcRu0'><q id='tcRu0'><span id='tcRu0'><b id='tcRu0'><form id='tcRu0'><ins id='tcRu0'></ins><ul id='tcRu0'></ul><sub id='tcRu0'></sub></form><legend id='tcRu0'></legend><bdo id='tcRu0'><pre id='tcRu0'><center id='tcRu0'></center></pre></bdo></b><th id='tcRu0'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='tcRu0'><tfoot id='tcRu0'></tfoot><dl id='tcRu0'><fieldset id='tcRu0'></fieldset></dl></div>
              <bdo id='tcRu0'></bdo><ul id='tcRu0'></ul>
              • 本文介紹了擴展 mysqli_result的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我擴展了 PHP 的 mysqli 類,效果很好.但是如何讓它在查詢時返回自定義結果對象(或用于插入/更新/刪除等的布爾值)?

                I have extended PHP's mysqli class, which works fine. But how can I make it return a custom result object (or a boolean for insert/update/delete etc) when querying?

                namespace MyApp;
                class MySQLi extends mysqli {
                    public function query($query, $resultmode = null) {
                        // This needs to return a MySQLiResult or a boolean
                    }
                }
                class MySQLiResult extends mysqli_result {
                }
                

                這樣做我可以返回一個 MySQLiResult 對象,但我無法弄清楚如何為非基于選擇的查詢返回一個布爾值:

                Doing this I can return a MySQLiResult object, but I can't figure out how to return a boolean for non select based queries:

                public function query($query, $resultmode = null) {
                    $this->real_query($query); 
                    return new MySQLiResult($this);
                }
                

                更新:

                這是我最終使用的:

                class MySQLi extends mysqli {
                
                    public function query($query, $resultmode = null) {
                        $result = parent::query($query, $resultmode);
                        return is_bool($result) ? $result : new MySQLiResult($result);
                    }
                
                }
                
                
                class MySQLiResult {
                
                    private $result;
                
                    public function __construct(mysqli_result $result) {
                        $this->result = $result;
                    }
                
                    public function __call($name, $arguments) {
                        return call_user_func_array(array($this->result, $name), $arguments);
                    }
                
                    public function __set($name, $value) {
                        $this->result->$name = $value;
                    }
                
                    public function __get($name) {
                        return $this->result->$name;
                    }
                
                }
                

                推薦答案

                可能最簡單的做法是將 MySQLiResult 類視為 mysqli_result 的裝飾器.例如

                Probably the simplest thing to do would be treat your MySQLiResult class as a decorator for mysqli_result. For example

                class MySQLiResult
                {
                    private $result;
                
                    public function __construct(mysqli_result $result)
                    {
                        $this->result = $result;
                    }
                }
                

                然后,您可以將方法調用代理到內部結果并在需要時進行裝飾(添加功能).

                You could then proxy method calls to the internal result and decorate (add functionality) where required.

                這篇關于擴展 mysqli_result的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                相關文檔推薦

                store_result() and get_result() in mysql returns false(mysql 中的 store_result() 和 get_result() 返回 false)
                Call to undefined function mysqli_result::num_rows()(調用未定義的函數 mysqli_result::num_rows())
                PHP Prepared Statement Problems(PHP 準備好的語句問題)
                mysqli_fetch_array returning only one result(mysqli_fetch_array 只返回一個結果)
                PHP MySQLi Multiple Inserts(PHP MySQLi 多次插入)
                How do I make sure that values from MySQL keep their type in PHP?(如何確保 MySQL 中的值在 PHP 中保持其類型?)

                    <tbody id='t2G9S'></tbody>
                  <legend id='t2G9S'><style id='t2G9S'><dir id='t2G9S'><q id='t2G9S'></q></dir></style></legend>

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

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

                        1. 主站蜘蛛池模板: 日韩欧美一区二区三区免费观看 | 欧美日韩大片 | 亚洲444eee在线观看 | 中国一级特黄毛片大片 | 欧美久久一级特黄毛片 | 日韩精品国产精品 | 国产伦一区二区三区久久 | 一区中文字幕 | 久草精品在线 | 欧美成人aaa级毛片在线视频 | 欧美xxxx网站 | 精品国产91久久久久久 | 91在线看视频 | 夜夜草 | 色婷婷综合久久久中字幕精品久久 | 青青久在线视频 | 久色网 | 国产精品有限公司 | 羞羞视频在线观看 | 特黄av| 91文字幕巨乱亚洲香蕉 | 国产精品成人一区 | 日韩中文字幕在线观看 | 怡红院免费的全部视频 | 亚洲综合久久久 | 欧美日韩在线一区二区 | 成人在线观看免费爱爱 | 欧美1—12sexvideos | 中文字幕久久久 | 一区二区三区在线观看视频 | 四虎最新地址 | 夫妻午夜影院 | 91日韩在线 | 成人蜜桃av | 精品成人在线视频 | 久久只有精品 | 欧美视频精品 | 极品电影院 | 日韩av电影在线观看 | 国产美女精品视频免费观看 | 日韩影院在线观看 |