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

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

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

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

      • <bdo id='PUWV4'></bdo><ul id='PUWV4'></ul>

      <tfoot id='PUWV4'></tfoot>
      1. 如何在節點 js mysql 查詢函數中找到匿名函數之外

        how can find return variable value outside anonymous function in node js mysql query function(如何在節點 js mysql 查詢函數中找到匿名函數之外的返回變量值)

        <tfoot id='qI28x'></tfoot><legend id='qI28x'><style id='qI28x'><dir id='qI28x'><q id='qI28x'></q></dir></style></legend>

            • <bdo id='qI28x'></bdo><ul id='qI28x'></ul>

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

                <tbody id='qI28x'></tbody>
                  <i id='qI28x'><tr id='qI28x'><dt id='qI28x'><q id='qI28x'><span id='qI28x'><b id='qI28x'><form id='qI28x'><ins id='qI28x'></ins><ul id='qI28x'></ul><sub id='qI28x'></sub></form><legend id='qI28x'></legend><bdo id='qI28x'><pre id='qI28x'><center id='qI28x'></center></pre></bdo></b><th id='qI28x'></th></span></q></dt></tr></i><div class="zhxjpd5" id='qI28x'><tfoot id='qI28x'></tfoot><dl id='qI28x'><fieldset id='qI28x'></fieldset></dl></div>
                • 本文介紹了如何在節點 js mysql 查詢函數中找到匿名函數之外的返回變量值的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  你好朋友,我是 node js 的新手,我們如何獲取 mysql 查詢匿名函數中使用的變量值?

                  Hello friend i am new in node js, how we can get variable value used in mysql query anonymous function ?

                  var alldata = function(){
                  
                  var http = require('http'), mysql = require('mysql');
                  
                  var client = mysql.createConnection({
                         host: '127.0.0.1',
                     user: 'root',
                     password: ''
                  });
                  
                  client.connect();
                  client.query("use cakephp2");
                  
                  client.query("SELECT id, title,body,created from posts", 
                          function(err, results, fields) {
                              if (err) throw err;
                  
                              var output = '<h1>Latest Posts</h1><ul><table border=1><tr>';
                              for (var index in fields) {
                                  output += '<td>' + fields[index].name + '</td>';
                              }
                              output += '</tr>';
                              for (var index in results) {
                                  output += '<tr><td>' + results[index].id + '</td>';
                                  output += '<td>' + results[index].title + '</td>';
                                  output += '<td>' + results[index].body + '</td>';
                                  output += '<td>' + results[index].created + '</td></tr>';
                              }
                              output += '</ul>';
                              // console.log(output);
                              // return output;
                  
                          }
                      ); 
                    return  output ;
                  }
                  exports.alldatas = alldata();
                  

                  在上面的代碼中,當使用console.log(output)給出正確的結果時,在client.query中我沒有發現返回輸出結果,但不能訪問匿名函數之外的輸出值.

                  in above code i did not found return output result while in client.query when use console.log(output) give correct result, but can not access output value outside of anonymous function.

                  請幫幫我

                  提前致謝.

                  推薦答案

                  您將無法在回調函數之外訪問該變量.原因是,Node.js 有一個特殊功能,即在執行異步 IO 任務(在您的情況下為 mysql 查詢)后,將回調函數作為下一個要執行的代碼塊傳遞.

                  You won't be able to access that variable outside the callback function. The reason is, the Node.js has a special feature of passing a callback function as the next block of code to be executed after performing an asynchronous IO task, (in your case a mysql query).

                  當您的程序進入 IO 模式時,您在回調函數之后編寫的代碼會立即執行.并且 output 變量直到回調被觸發才準備好.因此您無法訪問它.

                  The code you write after the callback function gets executed immediately when your program goes into IO mode. And the output variable is not ready untill the callback is fired. and hence you can not access it.

                  您可以在此處

                  您必須在該回調函數中使用 output 或在那里調用其他函數并將 output 作為參數傳遞給它.

                  You will have to ue the output within that callback function or call some other function there and pass output to it as a parameter.

                  這篇關于如何在節點 js mysql 查詢函數中找到匿名函數之外的返回變量值的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  SQL query to get all products, categories and meta data woocommerce/wordpress(獲取所有產品、類別和元數據的 SQL 查詢 woocommerce/wordpress)
                  How to use MySQL in WSL (Windows Subsystem for Linux)?(如何在 WSL(Linux 的 Windows 子系統)中使用 MySQL?)
                  PowerShell MySQL Backup Script Error in Task Scheduler 0x00041301(任務計劃程序中的 PowerShell MySQL 備份腳本錯誤 0x00041301)
                  Import the data from the XML files into a MySQL database(將數據從 XML 文件導入 MySQL 數據庫)
                  installed Xampp on Windows 7 32-bit. Errors when starting(在 Windows 7 32 位上安裝 Xampp.啟動時的錯誤)
                  Mysql lower case table on Windows xampp(Windows xampp 上的 Mysql 小寫表)
                • <tfoot id='aQnu1'></tfoot>

                      <tbody id='aQnu1'></tbody>
                    1. <small id='aQnu1'></small><noframes id='aQnu1'>

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

                            <i id='aQnu1'><tr id='aQnu1'><dt id='aQnu1'><q id='aQnu1'><span id='aQnu1'><b id='aQnu1'><form id='aQnu1'><ins id='aQnu1'></ins><ul id='aQnu1'></ul><sub id='aQnu1'></sub></form><legend id='aQnu1'></legend><bdo id='aQnu1'><pre id='aQnu1'><center id='aQnu1'></center></pre></bdo></b><th id='aQnu1'></th></span></q></dt></tr></i><div class="ndllh3p" id='aQnu1'><tfoot id='aQnu1'></tfoot><dl id='aQnu1'><fieldset id='aQnu1'></fieldset></dl></div>
                          1. 主站蜘蛛池模板: 集装箱展厅-住人集装箱住宿|建筑|房屋|集装箱售楼处-山东锐嘉科技工程有限公司 | 齿轮减速机_齿轮减速电机-VEMT蜗轮蜗杆减速机马达生产厂家瓦玛特传动瑞环机电 | 合肥卓创建筑装饰,专业办公室装饰、商业空间装修与设计。 | 工业设计,人工智能,体验式3D展示的智能技术交流服务平台-纳金网 J.S.Bach 圣巴赫_高端背景音乐系统_官网 | 电动葫芦|手拉葫芦|环链电动葫芦|微型电动葫芦-北京市凌鹰起重机械有限公司 | 浇注料-高铝砖耐火砖-郑州凯瑞得窑炉耐火材料有限公司 | 消泡剂-水处理消泡剂-涂料消泡剂-切削液消泡剂价格-东莞德丰消泡剂厂家 | 柴油机_柴油发电机_厂家_品牌-江苏卡得城仕发动机有限公司 | 热工多功能信号校验仪-热电阻热电偶校验仿真仪-金湖虹润仪表 | 防爆型气象站_农业气象站_校园气象站_农业四情监测系统「山东万象环境科技有限公司」 | 两头忙,井下装载机,伸缩臂装载机,30装载机/铲车,50装载机/铲车厂家_价格-莱州巨浪机械有限公司 | 石磨面粉机|石磨面粉机械|石磨面粉机组|石磨面粉成套设备-河南成立粮油机械有限公司 | 注塑模具_塑料模具_塑胶模具_范仕达【官网】_东莞模具设计与制造加工厂家 | 外观设计_设备外观设计_外观设计公司_产品外观设计_机械设备外观设计_东莞工业设计公司-意品深蓝 | 衬塑管道_衬四氟管道厂家-淄博恒固化工设备有限公司 | 讲师宝经纪-专业培训机构师资供应商_培训机构找讲师、培训师、讲师经纪就上讲师宝经纪 | MES系统-WMS系统-MES定制开发-制造执行MES解决方案-罗浮云计算 | 聚合氯化铝厂家-聚合氯化铝铁价格-河南洁康环保科技 | 生产自动包装秤_颗粒包装秤_肥料包装秤等包装机械-郑州鑫晟重工科技有限公司 | 雾度仪_雾度计_透光率雾度仪价格-三恩时(3nh)光电雾度仪厂家 | 骁龙云呼电销防封号系统-axb电销平台-外呼稳定『免费试用』 | 气动机械手-搬运机械手-气动助力机械手-山东精瑞自动化设备有限公司 | HEYL硬度计量泵-荧光法在线溶解氧仪-净时测控技术(上海)有限公司 | 节流截止放空阀-不锈钢阀门-气动|电动截止阀-鸿华阀门有限公司 | 消泡剂-水处理消泡剂-涂料消泡剂-切削液消泡剂价格-东莞德丰消泡剂厂家 | 定制/定做冲锋衣厂家/公司-订做/订制冲锋衣价格/费用-北京圣达信 | 上海小程序开发-上海小程序制作公司-上海网站建设-公众号开发运营-软件外包公司-咏熠科技 | 培训中心-翰香原香酥板栗饼加盟店总部-正宗板栗酥饼技术 | 石栏杆_青石栏杆_汉白玉栏杆_花岗岩栏杆 - 【石雕之乡】点石石雕石材厂 | 东莞螺丝|东莞螺丝厂|东莞不锈钢螺丝|东莞组合螺丝|东莞精密螺丝厂家-东莞利浩五金专业紧固件厂家 | 河南正规膏药生产厂家-膏药贴牌-膏药代加工-修康药业集团官网 | 软文发布-新闻发布推广平台-代写文章-网络广告营销-自助发稿公司媒介星 | 通风气楼_通风天窗_屋顶风机-山东美创通风设备有限公司 | 东莞螺杆空压机_永磁变频空压机_节能空压机_空压机工厂批发_深圳螺杆空压机_广州螺杆空压机_东莞空压机_空压机批发_东莞空压机工厂批发_东莞市文颖设备科技有限公司 | 阿米巴企业经营-阿米巴咨询管理-阿米巴企业培训-广东键锋企业管理咨询有限公司 | 刑事律师_深圳著名刑事辩护律师_王平聚【清华博士|刑法教授】 | 分光色差仪,测色仪,反透射灯箱,爱色丽分光光度仪,美能达色差仪维修_苏州欣美和仪器有限公司 | 企业微信营销_企业微信服务商_私域流量运营_艾客SCRM官网 | 阳光1号桔柚_无核沃柑_柑橘新品种枝条苗木批发 - 苧金网 | 德国EA可编程直流电源_电子负载,中国台湾固纬直流电源_交流电源-苏州展文电子科技有限公司 | 喷砂机厂家_自动喷砂机生产_新瑞自动化喷砂除锈设备 |