{"id":48685,"date":"2024-12-02T11:07:11","date_gmt":"2024-12-02T03:07:11","guid":{"rendered":"https:\/\/fwq.ai\/blog\/48685\/"},"modified":"2024-12-02T11:07:11","modified_gmt":"2024-12-02T03:07:11","slug":"%e5%be%ae%e4%bf%a1%e5%bc%80%e5%8f%91%e4%b8%ad%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3mysql%e6%8f%92%e5%85%a5text%e5%ad%97%e6%ae%b5%e4%b9%b1%e7%a0%81%e9%97%ae%e9%a2%98%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/48685\/","title":{"rendered":"\u5fae\u4fe1\u5f00\u53d1\u4e2d\u5982\u4f55\u89e3\u51b3MySQL\u63d2\u5165Text\u5b57\u6bb5\u4e71\u7801\u95ee\u9898\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u5fae\u4fe1\u5f00\u53d1\u4e2d\u5982\u4f55\u89e3\u51b3MySQL\u63d2\u5165Text\u5b57\u6bb5\u4e71\u7801\u95ee\u9898\uff1f<\/h1>\n<p><span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u4e0d\u77e5\u9053\u5927\u5bb6\u662f\u5426\u719f\u6089\uff1f\u4eca\u5929\u6211\u5c06\u7ed9\u5927\u5bb6\u4ecb\u7ecd<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u5fae\u4fe1\u5f00\u53d1\u4e2d\u5982\u4f55\u89e3\u51b3MySQL\u63d2\u5165Text\u5b57\u6bb5\u4e71\u7801\u95ee\u9898\uff1f\u300b<\/span>\uff0c\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u4f1a\u8bb2\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u5982\u679c\u4f60\u5728\u770b\u5b8c\u672c\u7bc7\u6587\u7ae0\u540e\uff0c\u6709\u66f4\u597d\u7684\u5efa\u8bae\u6216\u8005\u53d1\u73b0\u54ea\u91cc\u6709\u95ee\u9898\uff0c\u5e0c\u671b\u5927\u5bb6\u90fd\u80fd\u79ef\u6781\u8bc4\u8bba\u6307\u51fa\uff0c\u8c22\u8c22\uff01\u5e0c\u671b\u6211\u4eec\u80fd\u4e00\u8d77\u52a0\u6cb9\u8fdb\u6b65\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241030\/173024644067217728afe2d.jpg\" class=\"aligncenter\" title=\"\u5fae\u4fe1\u5f00\u53d1\u4e2d\u5982\u4f55\u89e3\u51b3MySQL\u63d2\u5165Text\u5b57\u6bb5\u4e71\u7801\u95ee\u9898\uff1f\u63d2\u56fe\" alt=\"\u5fae\u4fe1\u5f00\u53d1\u4e2d\u5982\u4f55\u89e3\u51b3MySQL\u63d2\u5165Text\u5b57\u6bb5\u4e71\u7801\u95ee\u9898\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5fae\u4fe1\u5f00\u53d1\u4e2d\u7684mysql\u63d2\u5165text\u5b57\u6bb5\u4e71\u7801\u95ee\u9898<\/strong><\/p>\n<p>\u5728\u5fae\u4fe1\u5f00\u53d1\u4e2d\uff0c\u5c06\u6c49\u5b57\u5185\u5bb9\u63d2\u5165\u5230mysql\u6570\u636e\u5e93\u4e2d\u7684text\u5b57\u6bb5\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u4e71\u7801\u95ee\u9898\u3002<\/p>\n<p><strong>\u95ee\u9898\u539f\u56e0\uff1a<\/strong><\/p>\n<p>\u5927\u591a\u6570\u60c5\u51b5\u4e0b\uff0c\u4e71\u7801\u95ee\u9898\u662f\u7531\u7f16\u7801\u5dee\u5f02\u9020\u6210\u7684\u3002\u5fae\u4fe1\u6d88\u606f\u63a5\u6536\u5904\u7406\u8fc7\u7a0b\u4e2d\u4f7f\u7528\u7684\u7f16\u7801\u4e0e\u6570\u636e\u5e93\u4e2d\u5b58\u50a8\u4f7f\u7528\u7684\u7f16\u7801\u4e0d\u4e00\u81f4\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n<p>\u53c2\u8003\u535a\u5ba2\u56ed\u6587\u7ae0\u300a\u89e3\u51b3c#\u5fae\u4fe1auto\u56de\u590dmysql\u50a8\u5b58\u4e71\u7801\u7684\u95ee\u9898\u300b\u4e2d\u7684\u65b9\u6cd5\uff1a<\/p>\n<ol>\n<li>\u901a\u8fc7\u5fae\u4fe1\u63a5\u53e3\u63a5\u6536\u6d88\u606f\uff0c\u4f7f\u7528utf-8\u7f16\u7801\u89e3\u7801\u62a5\u6587\u5185\u5bb9\u3002<\/li>\n<li>\u5c06\u89e3\u7801\u540e\u7684\u5185\u5bb9\u901a\u8fc7mysql\u5b58\u50a8\u8fc7\u7a0b\u8fdb\u884c\u63d2\u5165\uff0c\u6307\u5b9a\u5b58\u50a8\u8fc7\u7a0b\u7684\u5b57\u7b26\u96c6\u4e3autf-8\u3002<\/li>\n<\/ol>\n<p>\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li>\n<p>\u4f7f\u7528php\u63a5\u6536\u5fae\u4fe1\u6d88\u606f\uff0c\u89e3\u7801\u62a5\u6587\u5185\u5bb9\uff1a<\/p>\n<pre>$poststr = file_get_contents('php:\/\/input');\n$xmlobj = simplexml_load_string($poststr, 'simplexmlelement', libxml_nocdata);\n$content = $xmlobj-&gt;content[0];\n$content = iconv('utf-8', 'gbk', $content); \/\/ \u89e3\u7801\u4e3agbk\u7f16\u7801<\/pre>\n<\/li>\n<li>\n<p>\u4f7f\u7528mysql\u5b58\u50a8\u8fc7\u7a0b\u8fdb\u884c\u63d2\u5165\uff1a<\/p>\n<pre>create procedure insertmessage(in msg text)\ncharset utf8\nbegin\n  insert into message(msg) values (msg);\nend;<\/pre>\n<\/li>\n<li>\n<p>\u8c03\u7528\u5b58\u50a8\u8fc7\u7a0b\u63d2\u5165\u5185\u5bb9\uff1a<\/p>\n<pre>$sql = \"CALL InsertMessage('$content')\";\n$mysqli-&gt;query($sql);<\/pre>\n<\/li>\n<\/ol>\n<p>\u8fd9\u6837\uff0c\u63d2\u5165\u6570\u636e\u5e93\u4e2d\u7684\u5185\u5bb9\u5c31\u4e0d\u4f1a\u518d\u4e71\u7801\u3002<\/p>\n<p>\u597d\u4e86\uff0c\u672c\u6587\u5230\u6b64\u7ed3\u675f\uff0c\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u300a\u5fae\u4fe1\u5f00\u53d1\u4e2d\u5982\u4f55\u89e3\u51b3MySQL\u63d2\u5165Text\u5b57\u6bb5\u4e71\u7801\u95ee\u9898\uff1f\u300b\uff0c\u5e0c\u671b\u672c\u6587\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff01\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff0c\u7ed9\u5927\u5bb6\u5206\u4eab\u66f4\u591a\u6587\u7ae0\u77e5\u8bc6\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5fae\u4fe1\u5f00\u53d1\u4e2d\u5982\u4f55\u89e3\u51b3MySQL\u63d2\u5165Text\u5b57\u6bb5\u4e71\u7801\u95ee\u9898\uff1f \u6587\u7ae0\u4e0d\u77e5\u9053\u5927\u5bb6\u662f\u5426\u719f\u6089\uff1f\u4eca\u5929\u6211\u5c06\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u300a\u5fae\u4fe1\u5f00\u53d1\u4e2d\u5982\u4f55\u89e3\u51b3MySQL\u63d2\u5165Text\u5b57\u6bb5\u4e71\u7801\u95ee\u9898\uff1f\u300b\uff0c\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u4f1a\u8bb2\u5230\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u5982\u679c\u4f60\u5728\u770b\u5b8c\u672c\u7bc7\u6587\u7ae0\u540e\uff0c\u6709\u66f4\u597d\u7684\u5efa\u8bae\u6216\u8005\u53d1\u73b0\u54ea\u91cc\u6709\u95ee\u9898\uff0c\u5e0c\u671b\u5927\u5bb6\u90fd\u80fd\u79ef\u6781\u8bc4\u8bba\u6307\u51fa\uff0c\u8c22\u8c22\uff01\u5e0c\u671b\u6211\u4eec\u80fd\u4e00\u8d77\u52a0\u6cb9\u8fdb\u6b65\uff01 \u5fae\u4fe1\u5f00\u53d1\u4e2d\u7684mysql\u63d2\u5165text\u5b57\u6bb5\u4e71\u7801\u95ee\u9898 \u5728\u5fae\u4fe1\u5f00\u53d1\u4e2d\uff0c\u5c06\u6c49\u5b57\u5185\u5bb9\u63d2\u5165\u5230mysql\u6570\u636e\u5e93\u4e2d\u7684text\u5b57\u6bb5\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u4e71\u7801\u95ee\u9898\u3002 \u95ee\u9898\u539f\u56e0\uff1a \u5927\u591a\u6570\u60c5\u51b5\u4e0b\uff0c\u4e71\u7801\u95ee\u9898\u662f\u7531\u7f16\u7801\u5dee\u5f02\u9020\u6210\u7684\u3002\u5fae\u4fe1\u6d88\u606f\u63a5\u6536\u5904\u7406\u8fc7\u7a0b\u4e2d\u4f7f\u7528\u7684\u7f16\u7801\u4e0e\u6570\u636e\u5e93\u4e2d\u5b58\u50a8\u4f7f\u7528\u7684\u7f16\u7801\u4e0d\u4e00\u81f4\u3002 \u89e3\u51b3\u65b9\u6848\uff1a \u53c2\u8003\u535a\u5ba2\u56ed\u6587\u7ae0\u300a\u89e3\u51b3c#\u5fae\u4fe1auto\u56de\u590dmysql\u50a8\u5b58\u4e71\u7801\u7684\u95ee\u9898\u300b\u4e2d\u7684\u65b9\u6cd5\uff1a \u901a\u8fc7\u5fae\u4fe1\u63a5\u53e3\u63a5\u6536\u6d88\u606f\uff0c\u4f7f\u7528utf-8\u7f16\u7801\u89e3\u7801\u62a5\u6587\u5185\u5bb9\u3002 \u5c06\u89e3\u7801\u540e\u7684\u5185\u5bb9\u901a\u8fc7mysql\u5b58\u50a8\u8fc7\u7a0b\u8fdb\u884c\u63d2\u5165\uff0c\u6307\u5b9a\u5b58\u50a8\u8fc7\u7a0b\u7684\u5b57\u7b26\u96c6\u4e3autf-8\u3002 \u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a \u4f7f\u7528php\u63a5\u6536\u5fae\u4fe1\u6d88\u606f\uff0c\u89e3\u7801\u62a5\u6587\u5185\u5bb9\uff1a $poststr = file_get_contents(&#8216;php:\/\/input&#8217;); $xmlobj = simplexml_load_string($poststr, &#8216;simplexmlelement&#8217;, libxml_nocdata); $content = $xmlobj-&gt;content[0]; $content = iconv(&#8216;utf-8&#8217;, &#8216;gbk&#8217;, $content); \/\/ \u89e3\u7801\u4e3agbk\u7f16\u7801 \u4f7f\u7528mysql\u5b58\u50a8\u8fc7\u7a0b\u8fdb\u884c\u63d2\u5165\uff1a create procedure insertmessage(in msg text) charset utf8 begin insert into message(msg) values (msg); end; \u8c03\u7528\u5b58\u50a8\u8fc7\u7a0b\u63d2\u5165\u5185\u5bb9\uff1a $sql = &#8220;CALL InsertMessage(&#8216;$content&#8217;)&#8221;; $mysqli-&gt;query($sql); \u8fd9\u6837\uff0c\u63d2\u5165\u6570\u636e\u5e93\u4e2d\u7684\u5185\u5bb9\u5c31\u4e0d\u4f1a\u518d\u4e71\u7801\u3002 \u597d\u4e86\uff0c\u672c\u6587\u5230\u6b64\u7ed3\u675f\uff0c\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u300a\u5fae\u4fe1\u5f00\u53d1\u4e2d\u5982\u4f55\u89e3\u51b3MySQL\u63d2\u5165Text\u5b57\u6bb5\u4e71\u7801\u95ee\u9898\uff1f\u300b\uff0c\u5e0c\u671b\u672c\u6587\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff01\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff0c\u7ed9\u5927\u5bb6\u5206\u4eab\u66f4\u591a\u6587\u7ae0\u77e5\u8bc6\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-48685","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/48685","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=48685"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/48685\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=48685"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=48685"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=48685"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}