久久久久久久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. 如何在節點 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="qwawimqqmiuu" 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="qwawimqqmiuu" id='aQnu1'><tfoot id='aQnu1'></tfoot><dl id='aQnu1'><fieldset id='aQnu1'></fieldset></dl></div>
                          1. 主站蜘蛛池模板: 欧美精品欧美精品系列 | 国产精品久久久久久久久免费软件 | 精品美女 | 国产亚洲精品精品国产亚洲综合 | 91在线看 | 亚洲一区二区三区视频 | 99精品在线观看 | 国产成人福利 | 亚洲欧美日韩一区二区 | 国产午夜精品视频 | 久热精品在线 | 日本不卡视频在线播放 | 精品一区二区在线看 | www.婷婷亚洲基地 | 亚洲自拍偷拍欧美 | 成人精品高清 | 国产欧美日韩精品一区二区三区 | 玖玖视频国产 | 国产精品亚洲一区 | 亚洲国产乱码 | 日韩久久久久久 | 欧洲视频一区二区 | av在线黄 | 正在播放国产精品 | 高清国产午夜精品久久久久久 | 国产综合视频 | 成人免费片 | 91精品国产乱码久久久久久久久 | 亚洲视频在线看 | 日本一道本视频 | 国产日韩欧美一区二区 | 久久精品国产一区二区电影 | 日本不卡免费新一二三区 | 久久精品中文字幕 | 365夜爽爽欧美性午夜免费视频 | 欧美日韩精品一区 | 日韩在线免费视频 | 国产精品视频导航 | 国产99久久 | 国产精品夜色一区二区三区 | ririsao久久精品一区 |