{"id":146509,"date":"2024-11-01T11:46:20","date_gmt":"2024-11-01T03:46:20","guid":{"rendered":"https:\/\/server.hk\/cnblog\/146509\/"},"modified":"2024-11-01T11:46:20","modified_gmt":"2024-11-01T03:46:20","slug":"wex5%e6%95%b8%e6%93%9a%e5%ba%ab%e9%83%a8%e7%bd%b2%e5%85%a8%e6%94%bb%e7%95%a5%ef%bc%8c%e8%ae%93%e4%bd%a0%e5%bf%ab%e9%80%9f%e4%b8%8a%e6%89%8b-wex5%e9%83%a8%e7%bd%b2%e6%95%b8%e6%93%9a%e5%ba%ab","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/146509\/","title":{"rendered":"Wex5\u6578\u64da\u5eab\u90e8\u7f72\u5168\u653b\u7565\uff0c\u8b93\u4f60\u5feb\u901f\u4e0a\u624b (wex5\u90e8\u7f72\u6578\u64da\u5eab)"},"content":{"rendered":"<h1 id=\"wex5%e6%95%b8%e6%93%9a%e5%ba%ab%e9%83%a8%e7%bd%b2%e5%85%a8%e6%94%bb%e7%95%a5%ef%bc%8c%e8%ae%93%e4%bd%a0%e5%bf%ab%e9%80%9f%e4%b8%8a%e6%89%8b-GnHmHbZQLd\">Wex5\u6578\u64da\u5eab\u90e8\u7f72\u5168\u653b\u7565\uff0c\u8b93\u4f60\u5feb\u901f\u4e0a\u624b<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u6578\u64da\u9a45\u52d5\u6642\u4ee3\uff0c\u6578\u64da\u5eab\u7684\u90e8\u7f72\u8207\u7ba1\u7406\u8b8a\u5f97\u8d8a\u4f86\u8d8a\u91cd\u8981\u3002Wex5\u4f5c\u70ba\u4e00\u500b\u5f37\u5927\u7684\u958b\u767c\u6846\u67b6\uff0c\u63d0\u4f9b\u4e86\u9748\u6d3b\u7684\u6578\u64da\u5eab\u64cd\u4f5c\u529f\u80fd\uff0c\u8b93\u958b\u767c\u8005\u80fd\u5920\u5feb\u901f\u69cb\u5efa\u548c\u90e8\u7f72\u61c9\u7528\u7a0b\u5e8f\u3002\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0eWex5\u6578\u64da\u5eab\u7684\u90e8\u7f72\u904e\u7a0b\uff0c\u5e6b\u52a9\u4f60\u5feb\u901f\u4e0a\u624b\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%afwex5%ef%bc%9f-GnHmHbZQLd\">\u4ec0\u9ebc\u662fWex5\uff1f<\/h2>\n<p>Wex5\u662f\u4e00\u500b\u57fa\u65bcJavaScript\u7684\u958b\u767c\u6846\u67b6\uff0c\u5c08\u6ce8\u65bc\u5feb\u901f\u958b\u767cWeb\u61c9\u7528\u7a0b\u5e8f\u3002\u5b83\u63d0\u4f9b\u4e86\u8c50\u5bcc\u7684\u529f\u80fd\uff0c\u5305\u62ec\u6578\u64da\u5eab\u64cd\u4f5c\u3001\u7528\u6236\u754c\u9762\u8a2d\u8a08\u548cAPI\u96c6\u6210\u7b49\u3002Wex5\u7684\u6578\u64da\u5eab\u529f\u80fd\u4f7f\u5f97\u958b\u767c\u8005\u80fd\u5920\u8f15\u9b06\u5730\u8207\u5404\u7a2e\u6578\u64da\u5eab\u9032\u884c\u4ea4\u4e92\uff0c\u7121\u8ad6\u662f\u95dc\u4fc2\u578b\u6578\u64da\u5eab\u9084\u662f\u975e\u95dc\u4fc2\u578b\u6578\u64da\u5eab\u3002<\/p>\n<h2 id=\"wex5%e6%95%b8%e6%93%9a%e5%ba%ab%e9%83%a8%e7%bd%b2%e7%9a%84%e6%ba%96%e5%82%99%e5%b7%a5%e4%bd%9c-GnHmHbZQLd\">Wex5\u6578\u64da\u5eab\u90e8\u7f72\u7684\u6e96\u5099\u5de5\u4f5c<\/h2>\n<p>\u5728\u958b\u59cb\u90e8\u7f72Wex5\u6578\u64da\u5eab\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u9032\u884c\u4e00\u4e9b\u6e96\u5099\u5de5\u4f5c\uff1a<\/p>\n<ul>\n<li><strong>\u9078\u64c7\u6578\u64da\u5eab\u985e\u578b\uff1a<\/strong>Wex5\u652f\u6301\u591a\u7a2e\u6578\u64da\u5eab\uff0c\u5305\u62ecMySQL\u3001PostgreSQL\u548cMongoDB\u7b49\u3002\u6839\u64da\u60a8\u7684\u9700\u6c42\u9078\u64c7\u5408\u9069\u7684\u6578\u64da\u5eab\u3002<\/li>\n<li><strong>\u5b89\u88dd\u6578\u64da\u5eab\u670d\u52d9\uff1a<\/strong>\u78ba\u4fdd\u60a8\u5df2\u7d93\u5728\u4f3a\u670d\u5668\u4e0a\u5b89\u88dd\u4e86\u6240\u9078\u7684\u6578\u64da\u5eab\u670d\u52d9\uff0c\u4e26\u4e14\u80fd\u5920\u6b63\u5e38\u904b\u884c\u3002<\/li>\n<li><strong>\u914d\u7f6e\u6578\u64da\u5eab\u9023\u63a5\uff1a<\/strong>\u6e96\u5099\u597d\u6578\u64da\u5eab\u7684\u9023\u63a5\u4fe1\u606f\uff0c\u5305\u62ec\u4e3b\u6a5f\u5730\u5740\u3001\u7aef\u53e3\u865f\u3001\u7528\u6236\u540d\u548c\u5bc6\u78bc\u3002<\/li>\n<\/ul>\n<h2 id=\"wex5%e6%95%b8%e6%93%9a%e5%ba%ab%e7%9a%84%e5%9f%ba%e6%9c%ac%e9%85%8d%e7%bd%ae-GnHmHbZQLd\">Wex5\u6578\u64da\u5eab\u7684\u57fa\u672c\u914d\u7f6e<\/h2>\n<p>\u5728Wex5\u4e2d\u914d\u7f6e\u6578\u64da\u5eab\u76f8\u5c0d\u7c21\u55ae\u3002\u4ee5\u4e0b\u662f\u57fa\u672c\u7684\u914d\u7f6e\u6b65\u9a5f\uff1a<\/p>\n<pre><code>\n\/\/ \u5728Wex5\u4e2d\u914d\u7f6e\u6578\u64da\u5eab\u9023\u63a5\nvar dbConfig = {\n    host: 'localhost', \/\/ \u6578\u64da\u5eab\u4e3b\u6a5f\n    port: 3306, \/\/ \u6578\u64da\u5eab\u7aef\u53e3\n    user: 'your_username', \/\/ \u6578\u64da\u5eab\u7528\u6236\u540d\n    password: 'your_password', \/\/ \u6578\u64da\u5eab\u5bc6\u78bc\n    database: 'your_database' \/\/ \u6578\u64da\u5eab\u540d\u7a31\n};\n\n\/\/ \u5275\u5efa\u6578\u64da\u5eab\u9023\u63a5\nvar connection = mysql.createConnection(dbConfig);\n<\/code><\/pre>\n<p>\u5728\u4e0a\u8ff0\u4ee3\u78bc\u4e2d\uff0c\u60a8\u9700\u8981\u6839\u64da\u5be6\u969b\u60c5\u6cc1\u66ff\u63db\u6578\u64da\u5eab\u7684\u9023\u63a5\u4fe1\u606f\u3002\u9019\u6a23\u5c31\u53ef\u4ee5\u5efa\u7acb\u8207\u6578\u64da\u5eab\u7684\u9023\u63a5\u3002<\/p>\n<h2 id=\"%e6%95%b8%e6%93%9a%e5%ba%ab%e6%93%8d%e4%bd%9c%e7%a4%ba%e4%be%8b-GnHmHbZQLd\">\u6578\u64da\u5eab\u64cd\u4f5c\u793a\u4f8b<\/h2>\n<p>\u4e00\u65e6\u914d\u7f6e\u5b8c\u6210\uff0c\u60a8\u5c31\u53ef\u4ee5\u958b\u59cb\u9032\u884c\u6578\u64da\u5eab\u64cd\u4f5c\u4e86\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u898b\u7684\u6578\u64da\u5eab\u64cd\u4f5c\u793a\u4f8b\uff1a<\/p>\n<h3 id=\"%e6%8f%92%e5%85%a5%e6%95%b8%e6%93%9a-GnHmHbZQLd\">\u63d2\u5165\u6578\u64da<\/h3>\n<pre><code>\nvar insertQuery = 'INSERT INTO users (name, email) VALUES (?, ?)';\nconnection.query(insertQuery, ['John Doe', 'john@example.com'], function (error, results) {\n    if (error) throw error;\n    console.log('\u6578\u64da\u63d2\u5165\u6210\u529f\uff0cID\u70ba\uff1a' + results.insertId);\n});\n<\/code><\/pre>\n<h3 id=\"%e6%9f%a5%e8%a9%a2%e6%95%b8%e6%93%9a-GnHmHbZQLd\">\u67e5\u8a62\u6578\u64da<\/h3>\n<pre><code>\nvar selectQuery = 'SELECT * FROM users';\nconnection.query(selectQuery, function (error, results) {\n    if (error) throw error;\n    console.log('\u67e5\u8a62\u7d50\u679c\uff1a', results);\n});\n<\/code><\/pre>\n<h3 id=\"%e6%9b%b4%e6%96%b0%e6%95%b8%e6%93%9a-GnHmHbZQLd\">\u66f4\u65b0\u6578\u64da<\/h3>\n<pre><code>\nvar updateQuery = 'UPDATE users SET email = ? WHERE name = ?';\nconnection.query(updateQuery, ['john.doe@example.com', 'John Doe'], function (error, results) {\n    if (error) throw error;\n    console.log('\u6578\u64da\u66f4\u65b0\u6210\u529f\uff0c\u53d7\u5f71\u97ff\u7684\u884c\u6578\uff1a' + results.affectedRows);\n});\n<\/code><\/pre>\n<h3 id=\"%e5%88%aa%e9%99%a4%e6%95%b8%e6%93%9a-GnHmHbZQLd\">\u522a\u9664\u6578\u64da<\/h3>\n<pre><code>\nvar deleteQuery = 'DELETE FROM users WHERE name = ?';\nconnection.query(deleteQuery, ['John Doe'], function (error, results) {\n    if (error) throw error;\n    console.log('\u6578\u64da\u522a\u9664\u6210\u529f\uff0c\u53d7\u5f71\u97ff\u7684\u884c\u6578\uff1a' + results.affectedRows);\n});\n<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-GnHmHbZQLd\">\u7e3d\u7d50<\/h2>\n<p>Wex5\u63d0\u4f9b\u4e86\u4e00\u500b\u9748\u6d3b\u4e14\u5f37\u5927\u7684\u6578\u64da\u5eab\u64cd\u4f5c\u6846\u67b6\uff0c\u8b93\u958b\u767c\u8005\u80fd\u5920\u5feb\u901f\u4e0a\u624b\u4e26\u9032\u884c\u5404\u7a2e\u6578\u64da\u5eab\u64cd\u4f5c\u3002\u901a\u904e\u672c\u6587\u7684\u4ecb\u7d39\uff0c\u76f8\u4fe1\u60a8\u5df2\u7d93\u5c0dWex5\u6578\u64da\u5eab\u7684\u90e8\u7f72\u6709\u4e86\u6e05\u6670\u7684\u4e86\u89e3\u3002\u5982\u679c\u60a8\u9700\u8981\u7a69\u5b9a\u7684\u4f3a\u670d\u5668\u652f\u6301\u4f86\u904b\u884c\u60a8\u7684Wex5\u61c9\u7528\uff0c\u8003\u616e\u4f7f\u7528<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u6216<a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a>\uff0c\u4ee5\u78ba\u4fdd\u60a8\u7684\u61c9\u7528\u7a0b\u5e8f\u9ad8\u6548\u904b\u884c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u638c\u63e1Wex5\u6578\u64da\u5eab\u90e8\u7f72\u5168\u653b\u7565\uff0c\u5feb\u901f\u4e0a\u624b\uff0c\u8f15\u9b06\u914d\u7f6e\u8207\u7ba1\u7406\u6578\u64da\u5eab\uff0c\u63d0\u5347\u958b\u767c\u6548\u7387\u8207\u9805\u76ee\u6210\u529f\u7387\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-146509","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/146509","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=146509"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/146509\/revisions"}],"predecessor-version":[{"id":146510,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/146509\/revisions\/146510"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=146509"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=146509"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=146509"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}