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

  • <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="qwawimqqmiuu" 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. 如何在節(jié)點(diǎn) js mysql 查詢函數(shù)中找到匿名函數(shù)之外

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

        <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="qwawimqqmiuu" id='qI28x'><tfoot id='qI28x'></tfoot><dl id='qI28x'><fieldset id='qI28x'></fieldset></dl></div>
                • 本文介紹了如何在節(jié)點(diǎn) js mysql 查詢函數(shù)中找到匿名函數(shù)之外的返回變量值的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  限時送ChatGPT賬號..

                  你好朋友,我是 node js 的新手,我們?nèi)绾潍@取 mysql 查詢匿名函數(shù)中使用的變量值?

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

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

                  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.

                  請幫幫我

                  提前致謝.

                  推薦答案

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

                  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).

                  當(dāng)您的程序進(jìn)入 IO 模式時,您在回調(diào)函數(shù)之后編寫的代碼會立即執(zhí)行.并且 output 變量直到回調(diào)被觸發(fā)才準(zhǔn)備好.因此您無法訪問它.

                  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.

                  您可以在此處

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

                  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.

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

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

                  相關(guān)文檔推薦

                  SQL query to get all products, categories and meta data woocommerce/wordpress(獲取所有產(chǎn)品、類別和元數(shù)據(jù)的 SQL 查詢 woocommerce/wordpress)
                  How to use MySQL in WSL (Windows Subsystem for Linux)?(如何在 WSL(Linux 的 Windows 子系統(tǒng))中使用 MySQL?)
                  PowerShell MySQL Backup Script Error in Task Scheduler 0x00041301(任務(wù)計劃程序中的 PowerShell MySQL 備份腳本錯誤 0x00041301)
                  Import the data from the XML files into a MySQL database(將數(shù)據(jù)從 XML 文件導(dǎo)入 MySQL 數(shù)據(jù)庫)
                  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="qwawimqqmiuu" id='aQnu1'><tfoot id='aQnu1'></tfoot><dl id='aQnu1'><fieldset id='aQnu1'></fieldset></dl></div>
                          1. 主站蜘蛛池模板: 天天操天天摸天天爽 | 99精品网| 91精品国产一区二区三区香蕉 | 日韩欧美国产一区二区三区 | 91视频入口 | 日韩欧美一二三区 | 亚洲国产精品精华素 | 国产精品一区二区视频 | 999精品在线 | 五月激情六月婷婷 | 亚洲精品日韩在线 | 精品欧美色视频网站在线观看 | 久久精品国产一区二区 | 一区不卡在线观看 | 91精品综合久久久久久五月天 | 日韩综合 | 日韩av一区二区在线观看 | 久久r免费视频 | 欧美一级免费片 | 国产免费一区 | 91精品久久久久久久久中文字幕 | 亚洲欧美日韩精品久久亚洲区 | 免费看日韩视频 | 色综合国产 | 久久精品欧美电影 | 99精品免费久久久久久久久日本 | 欧美成人一区二区三区片免费 | 国产乱码精品1区2区3区 | 亚洲男人网 | 国产精品久久久久久久久污网站 | 国产精品久久久久免费 | 日韩三级视频 | 亚洲欧美日韩精品久久亚洲区 | 精品一区二区三区在线观看 | 欧美一区二区三区视频在线观看 | 亚洲一区二区黄 | 国产成人精品久久二区二区91 | 久久精品国产精品青草 | 欧美日韩亚洲成人 | 天天影视色综合 | 中文字幕第一页在线 |