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

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

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

<tfoot id='EAKIx'></tfoot>
  • <legend id='EAKIx'><style id='EAKIx'><dir id='EAKIx'><q id='EAKIx'></q></dir></style></legend>
      • <bdo id='EAKIx'></bdo><ul id='EAKIx'></ul>

      1. 我應該什么時候關閉 PHP 中的數據庫連接?

        When should I close a database connection in PHP?(我應該什么時候關閉 PHP 中的數據庫連接?)

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

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

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

                • 本文介紹了我應該什么時候關閉 PHP 中的數據庫連接?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我不像 php 開發人員,但我必須使用它,而且我并不真正了解 PHP 如何在會話期間處理內存分配.

                  I'm nothing like a php developer but I do have to use it and I'm not really aware on how PHP handle memory allocation during session.

                  我正在開發一個要求 HTTP 身份驗證的應用程序,一旦您登錄,您就可以通過一個漂亮的界面操作數據.
                  有人在另一篇文章中告訴我,我不應該在每次執行后關閉 mysql 數據連接,但我不知道在使用這個應用程序期間這個連接是如何保持內存的,因為在服務器端我不知道 PHP 保留了什么記憶與否.

                  I'm working on an application that ask for an HTTP authentication, once you're logged in you can manipulate data through a nice interface.
                  Someone told me on another post, that I shouldn't close the mysql data connection after every execution, but I don't know how this connection stay is memory during using this app because in the server side I have no idea what PHP keeps in memory or not.

                  所以我的問題是我應該使用單例連接到數據庫并且永??遠不要關閉它(因為我永遠不會知道應用程序何時不在使用中.或者我應該堅持我今天所做的:打開連接-->執行語句 --> 關閉連接.

                  So my question is should I use a singleton to connect to the db and never close it (because I will never know when the application is not in use. Or should I stand with what I do today: opening connection --> execute statement --> close connection.

                  PS:我正在使用 mysqli

                  PS: I'm using mysqli

                  編輯 1:
                  我的應用程序是用 MVC 模式設計的,意思是:

                  Edit 1:
                  My application is design with MVC pattern meaning :

                  |''''''''''|      |'''''''''''''|      |''''''''''''''|
                  | view.php |  ==> | control.php |  ==> | database.php |
                  |----------|      |_____________|      |______________|
                  

                  該模式允許視圖僅通過 control.php 與數據交互,然后從 database.php 調用函數到 SELECTEDIT數據.根據你給我的解釋,我應該說:

                  That pattern allow the view to interact with data only through the control.php which then call a function from database.php to SELECT or EDIT data. with the explanation you give me, I should put:

                  public function __destruct(){
                      mysql_close($this->connection);
                  }
                  

                  database.php中,但是當需要選擇或修改數據時加載該頁面,所以它只執行很短的時間,這意味著它仍然會在結束時關閉連接請求.

                  inside database.php, but that page is load when there's a need to select or modify data, so it's only executed for a short time, meaning it will still close the connection at the end of the request.

                  哪個給出了一個更精確的問題,即我應該將您提供的代碼放在哪里,或者我的模式是否與 PHP 相關?

                  Which gives a more precise question of where should I put the peace of code you provide, or does my pattern relevant in PHP ?

                  推薦答案

                  永遠不要為每個查詢都創建一個新的連接;您甚至不必手動關閉它.

                  Never create a new connection for every query; You don't even have to close it manually.

                  只需在頁面開頭創建連接

                  Just create the connection at the beginning of you page

                  看看:你如何在 php 中有效地連接到 mysql 而無需在每次查詢時重新連接

                  你可以使用這個:

                  public function __destruct()
                  {
                     mysql_close($this->connection);
                  }
                  

                  頁面關閉時調用

                  這篇關于我應該什么時候關閉 PHP 中的數據庫連接?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 中保持其類型?)

                      <legend id='DjLdC'><style id='DjLdC'><dir id='DjLdC'><q id='DjLdC'></q></dir></style></legend>
                      1. <small id='DjLdC'></small><noframes id='DjLdC'>

                            <bdo id='DjLdC'></bdo><ul id='DjLdC'></ul>
                            <tfoot id='DjLdC'></tfoot>
                              <tbody id='DjLdC'></tbody>
                            <i id='DjLdC'><tr id='DjLdC'><dt id='DjLdC'><q id='DjLdC'><span id='DjLdC'><b id='DjLdC'><form id='DjLdC'><ins id='DjLdC'></ins><ul id='DjLdC'></ul><sub id='DjLdC'></sub></form><legend id='DjLdC'></legend><bdo id='DjLdC'><pre id='DjLdC'><center id='DjLdC'></center></pre></bdo></b><th id='DjLdC'></th></span></q></dt></tr></i><div class="e0g20as" id='DjLdC'><tfoot id='DjLdC'></tfoot><dl id='DjLdC'><fieldset id='DjLdC'></fieldset></dl></div>
                            主站蜘蛛池模板: 工业铝型材-铝合金电机壳-铝排-气动执行器-山东永恒能源集团有限公司 | TTCMS自助建站_网站建设_自助建站_免费网站_免费建站_天天向上旗下品牌 | 高空重型升降平台_高空液压举升平台_高空作业平台_移动式升降机-河南华鹰机械设备有限公司 | 北京公积金代办/租房发票/租房备案-北京金鼎源公积金提取服务中心 | 小型铜米机-干式铜米机-杂线全自动铜米机-河南鑫世昌机械制造有限公司 | 欧版反击式破碎机-欧版反击破-矿山石料破碎生产线-青州奥凯诺机械 | 安徽免检低氮锅炉_合肥燃油锅炉_安徽蒸汽发生器_合肥燃气锅炉-合肥扬诺锅炉有限公司 | [官网]叛逆孩子管教_戒网瘾学校_全封闭问题青少年素质教育_新起点青少年特训学校 | 美能达分光测色仪_爱色丽分光测色仪-苏州方特电子科技有限公司 | 神马影院-实时更新秒播 | 上海阳光泵业制造有限公司 -【官方网站】 | 钢制拖链生产厂家-全封闭钢制拖链-能源钢铝拖链-工程塑料拖链-河北汉洋机械制造有限公司 | SMC-SMC电磁阀-日本SMC气缸-SMC气动元件展示网 | 交通信号灯生产厂家_红绿灯厂家_电子警察监控杆_标志杆厂家-沃霖电子科技 | 广州迈驰新GMP兽药包装机首页_药品包装机_中药散剂包装机 | 三效蒸发器_多效蒸发器价格_四效三效蒸发器厂家-青岛康景辉 | 飞歌臭氧发生器厂家_水处理臭氧发生器_十大臭氧消毒机品牌 | 送料机_高速冲床送料机_NC伺服滚轮送料机厂家-东莞市久谐自动化设备有限公司 | 中空玻璃生产线,玻璃加工设备,全自动封胶线,铝条折弯机,双组份打胶机,丁基胶/卧式/立式全自动涂布机,玻璃设备-山东昌盛数控设备有限公司 | 武汉高低温试验箱_恒温恒湿试验箱厂家-武汉蓝锐环境科技有限公司 | 贴片电感_贴片功率电感_贴片绕线电感_深圳市百斯特电子有限公司 贴片电容代理-三星电容-村田电容-风华电容-国巨电容-深圳市昂洋科技有限公司 | 超声波焊接机,振动摩擦焊接机,激光塑料焊接机,超声波焊接模具工装-德召尼克(常州)焊接科技有限公司 | 自进式锚杆-自钻式中空注浆锚杆-洛阳恒诺锚固锚杆生产厂家 | 快速门厂家批发_PVC快速卷帘门_高速门_高速卷帘门-广州万盛门业 快干水泥|桥梁伸缩缝止水胶|伸缩缝装置生产厂家-广东广航交通科技有限公司 | 【铜排折弯机,钢丝折弯成型机,汽车发泡钢丝折弯机,线材折弯机厂家,线材成型机,铁线折弯机】贝朗折弯机厂家_东莞市贝朗自动化设备有限公司 | 专业甜品培训学校_广东糖水培训_奶茶培训_特色小吃培训_广州烘趣甜品培训机构 | 汽车水泵_汽车水泵厂家-瑞安市骏迪汽车配件有限公司 | 折弯机-刨槽机-数控折弯机-数控刨槽机-数控折弯机厂家-深圳豐科机械有限公司 | 防爆正压柜厂家_防爆配电箱_防爆控制箱_防爆空调_-盛通防爆 | 广西教师资格网-广西教师资格证考试网 | 厦门ISO认证|厦门ISO9001认证|厦门ISO14001认证|厦门ISO45001认证-艾索咨询专注ISO认证行业 | 【北京写字楼出租_写字楼租赁_办公室出租网/出售】-远行地产官网 | 披萨石_披萨盘_电器家电隔热绵加工定制_佛山市南海区西樵南方综合保温材料厂 | 蔡司三坐标-影像测量机-3D扫描仪-蔡司显微镜-扫描电镜-工业CT-ZEISS授权代理商三本工业测量 | 空调风机,低噪声离心式通风机,不锈钢防爆风机,前倾皮带传动风机,后倾空调风机-山东捷风风机有限公司 | 集装箱箱号识别_自重载重图像识别_铁路车号自动识别_OCR图像识别 | 全自动烧卖机厂家_饺子机_烧麦机价格_小笼汤包机_宁波江北阜欣食品机械有限公司 | 江苏南京多语种翻译-专业翻译公司报价-正规商务翻译机构-南京华彦翻译服务有限公司 | 优考试_免费在线考试系统_培训考试系统_题库系统_组卷答题系统_匡优考试 | 缠膜机|缠绕包装机|无纺布包装机-济南达伦特机械设备有限公司 | 智能楼宇-楼宇自控系统-楼宇智能化-楼宇自动化-三水智能化 |