{"id":22942,"date":"2024-11-21T10:17:24","date_gmt":"2024-11-21T02:17:24","guid":{"rendered":"https:\/\/fwq.ai\/blog\/22942\/"},"modified":"2024-11-21T10:17:24","modified_gmt":"2024-11-21T02:17:24","slug":"thinkphp%e6%96%87%e4%bb%b6%e5%a6%82%e4%bd%95%e9%85%8d%e7%bd%ae","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/22942\/","title":{"rendered":"ThinkPHP\u6587\u4ef6\u5982\u4f55\u914d\u7f6e"},"content":{"rendered":"<p>1.\u5e38\u7528\u7684\u914d\u7f6e\u65b9\u5f0f\u662f<strong>\u5728\u5e94\u7528\u76ee\u5f55\u6216\u8005\u6a21\u5757\u76ee\u5f55\u4e0b\u9762\u7684 database.php\u4e2d\u6dfb\u52a0\u4e0b\u9762\u7684\u914d\u7f6e\u53c2\u6570\uff1a<\/strong><\/p>\n<pre>return&nbsp;[\n&nbsp;\n\u3000\u3000\/\/&nbsp;\u6570\u636e\u5e93\u7c7b\u578b\u3000\u3000'type'&nbsp;=&amp;gt;&nbsp;'mysql',\n&nbsp;\n\u3000\u3000\/\/&nbsp;\u6570\u636e\u5e93\u8fde\u63a5DSN\u914d\u7f6e\u3000\u3000'dsn'&nbsp;=&amp;gt;&nbsp;'',\n&nbsp;\n\u3000\u3000\/\/&nbsp;\u670d\u52a1\u5668\u5730\u5740\u3000\u3000'hostname'&nbsp;=&amp;gt;&nbsp;'127.0.0.1',\n&nbsp;\n\u3000\u3000\/\/&nbsp;\u6570\u636e\u5e93\u540d\u3000\u3000'database'&nbsp;=&amp;gt;&nbsp;'thinkphp',\n&nbsp;\n\u3000\u3000\/\/&nbsp;\u6570\u636e\u5e93\u7528\u6237\u540d\u3000\u3000'username'&nbsp;=&amp;gt;&nbsp;'root',\n&nbsp;\n\u3000\u3000\/\/&nbsp;\u6570\u636e\u5e93\u5bc6\u7801\u3000\u3000'password'&nbsp;=&amp;gt;&nbsp;'',\n&nbsp;\n\u3000\u3000\/\/&nbsp;\u6570\u636e\u5e93\u8fde\u63a5\u7aef\u53e3\u3000\u3000'hostport'&nbsp;=&amp;gt;&nbsp;'',\n&nbsp;\n\u3000\u3000\/\/&nbsp;\u6570\u636e\u5e93\u8fde\u63a5\u53c2\u6570\u3000\u3000'params'&nbsp;=&amp;gt;&nbsp;[],\n&nbsp;\n\u3000\u3000\/\/&nbsp;\u6570\u636e\u5e93\u7f16\u7801\u9ed8\u8ba4\u91c7\u7528utf8\u3000\u3000'charset'&nbsp;=&amp;gt;&nbsp;'utf8',\n&nbsp;\n\u3000\u3000\/\/&nbsp;\u6570\u636e\u5e93\u8868\u524d\u7f00\u3000\u3000'prefix'&nbsp;=&amp;gt;&nbsp;'think_',\n&nbsp;\n\u3000\u3000\/\/&nbsp;\u6570\u636e\u5e93\u8c03\u8bd5\u6a21\u5f0f\u3000\u3000'debug'&nbsp;=&amp;gt;&nbsp;false,\n&nbsp;\n\u3000\u3000\/\/&nbsp;\u6570\u636e\u5e93\u90e8\u7f72\u65b9\u5f0f:0&nbsp;\u96c6\u4e2d\u5f0f(\u5355\u4e00\u670d\u52a1\u5668),1&nbsp;\u5206\u5e03\u5f0f(\u4e3b\u4ece\u670d\u52a1\u5668)\u3000\u3000'deploy'&nbsp;=&amp;gt;&nbsp;0,\n&nbsp;\n\u3000\u3000\/\/&nbsp;\u6570\u636e\u5e93\u8bfb\u5199\u662f\u5426\u5206\u79bb&nbsp;\u4e3b\u4ece\u5f0f\u6709\u6548\u3000\u3000'rw_separate'&nbsp;=&amp;gt;&nbsp;false,\n&nbsp;\n\u3000\u3000\/\/&nbsp;\u8bfb\u5199\u5206\u79bb\u540e&nbsp;\u4e3b\u670d\u52a1\u5668\u6570\u91cf\u3000\u3000'master_num'&nbsp;=&amp;gt;&nbsp;1,\n&nbsp;\n\u3000\u3000\/\/&nbsp;\u6307\u5b9a\u4ece\u670d\u52a1\u5668\u5e8f\u53f7\u3000\u3000'slave_no'&nbsp;=&amp;gt;&nbsp;'',\n&nbsp;\n\/\/&nbsp;\u662f\u5426\u4e25\u683c\u68c0\u67e5\u5b57\u6bb5\u662f\u5426\u5b58\u5728\u3000\u3000'fields_strict'&nbsp;=&amp;gt;&nbsp;true,];<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>2.type\u53c2\u6570\u652f\u6301\u547d\u540d\u7a7a\u95f4\u5b8c\u6574\u5b9a\u4e49<\/strong>\uff0c\u4e0d\u5e26\u547d\u540d\u7a7a\u95f4\u5b9a\u4e49\u7684\u8bdd\uff0c\u9ed8\u8ba4\u91c7\u7528 hinkdbconnector \u4f5c\u4e3a\u547d\u540d\u7a7a\u95f4\uff0c\u5982\u679c\u4f7f\u7528\u5e94\u7528\u81ea\u5df1\u6269\u5c55\u7684\u6570\u636e\u5e93\u9a71\u52a8\uff0c\u53ef\u4ee5\u914d\u7f6e\u4e3a\uff1a<\/p>\n<pre>\/\/&nbsp;\u6570\u636e\u5e93\u7c7b\u578b\n&nbsp;\n'type'&nbsp;=&amp;gt;&nbsp;'orgdbMysql',<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8868\u793a\u6570\u636e\u5e93\u7684\u8fde\u63a5\u5668\u91c7\u7528&nbsp;orgdbMysql \u7c7b\u4f5c\u4e3a\u6570\u636e\u5e93\u8fde\u63a5\u9a71\u52a8\uff0c\u800c\u4e0d\u662f\u9ed8\u8ba4\u7684 hinkdbconnectorMysql \u3002<\/p>\n<p><strong>3.\u6bcf\u4e2a\u6a21\u5757\u53ef\u4ee5\u8bbe\u7f6e\u72ec\u7acb\u7684\u6570\u636e\u5e93\u8fde\u63a5\u53c2\u6570\uff0c<\/strong>\u5e76\u4e14\u76f8\u540c\u7684\u914d\u7f6e\u53c2\u6570\u53ef\u4ee5\u65e0\u9700\u91cd\u590d\u8bbe\u7f6e\uff0c\u4f8b\u5982\u6211\u4eec\u53ef\u4ee5\u5728admin\u6a21 \u5757\u7684database.php\u914d\u7f6e\u6587\u4ef6\u4e2d\u5b9a\u4e49\uff1a<\/p>\n<pre>return&nbsp;[\n&nbsp;\n\u3000\u3000\/\/&nbsp;\u670d\u52a1\u5668\u5730\u5740\u3000\u3000\n&nbsp;\n\u3000\u3000'hostname'&nbsp;=&amp;gt;&nbsp;'192.168.1.100',\n&nbsp;\n\u3000\u3000\/\/&nbsp;\u6570\u636e\u5e93\u540d\u3000\u3000\n&nbsp;\n'database'&nbsp;=&amp;gt;&nbsp;'admin',];<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8868\u793aadmin\u6a21\u5757\u7684\u6570\u636e\u5e93\u5730\u5740\u6539\u6210 192.168.1.100 \uff0c\u6570\u636e\u5e93\u540d\u6539\u6210 admin \uff0c\u5176\u5b83\u7684\u8fde\u63a5\u53c2\u6570\u548c\u5e94\u7528\u7684 database.php \u4e2d\u7684\u914d\u7f6e\u4e00\u6837\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fThinkPHP\u6587\u4ef6\u5982\u4f55\u914d\u7f6e\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1.\u5e38\u7528\u7684\u914d\u7f6e\u65b9\u5f0f\u662f\u5728\u5e94\u7528\u76ee\u5f55\u6216\u8005\u6a21\u5757\u76ee\u5f55\u4e0b\u9762\u7684 database.php\u4e2d\u6dfb\u52a0\u4e0b\u9762\u7684\u914d\u7f6e\u53c2\u6570\uff1a return&nbsp;[ &nbsp; \u3000\u3000\/\/&nbsp;\u6570\u636e\u5e93\u7c7b\u578b\u3000\u3000&#8217;type&#8217;&nbsp;=&amp;gt;&nbsp;&#8216;mysql&#8217;, &nbsp; \u3000\u3000\/\/&nbsp;\u6570\u636e\u5e93\u8fde\u63a5DSN\u914d\u7f6e\u3000\u3000&#8217;dsn&#8217;&nbsp;=&amp;gt;&nbsp;&#8221;, &nbsp; \u3000\u3000\/\/&nbsp;\u670d\u52a1\u5668\u5730\u5740\u3000\u3000&#8217;hostname&#8217;&nbsp;=&amp;gt;&nbsp;&#8216;127.0.0.1&#8217;, &nbsp; \u3000\u3000\/\/&nbsp;\u6570\u636e\u5e93\u540d\u3000\u3000&#8217;database&#8217;&nbsp;=&amp;gt;&nbsp;&#8216;thinkphp&#8217;, &nbsp; \u3000\u3000\/\/&nbsp;\u6570\u636e\u5e93\u7528\u6237\u540d\u3000\u3000&#8217;username&#8217;&nbsp;=&amp;gt;&nbsp;&#8216;root&#8217;, &nbsp; \u3000\u3000\/\/&nbsp;\u6570\u636e\u5e93\u5bc6\u7801\u3000\u3000&#8217;password&#8217;&nbsp;=&amp;gt;&nbsp;&#8221;, &nbsp; \u3000\u3000\/\/&nbsp;\u6570\u636e\u5e93\u8fde\u63a5\u7aef\u53e3\u3000\u3000&#8217;hostport&#8217;&nbsp;=&amp;gt;&nbsp;&#8221;, &nbsp; \u3000\u3000\/\/&nbsp;\u6570\u636e\u5e93\u8fde\u63a5\u53c2\u6570\u3000\u3000&#8217;params&#8217;&nbsp;=&amp;gt;&nbsp;[], &nbsp; \u3000\u3000\/\/&nbsp;\u6570\u636e\u5e93\u7f16\u7801\u9ed8\u8ba4\u91c7\u7528utf8\u3000\u3000&#8217;charset&#8217;&nbsp;=&amp;gt;&nbsp;&#8216;utf8&#8242;, &nbsp; \u3000\u3000\/\/&nbsp;\u6570\u636e\u5e93\u8868\u524d\u7f00\u3000\u3000&#8217;prefix&#8217;&nbsp;=&amp;gt;&nbsp;&#8216;think_&#8217;, &nbsp; \u3000\u3000\/\/&nbsp;\u6570\u636e\u5e93\u8c03\u8bd5\u6a21\u5f0f\u3000\u3000&#8217;debug&#8217;&nbsp;=&amp;gt;&nbsp;false, &nbsp; \u3000\u3000\/\/&nbsp;\u6570\u636e\u5e93\u90e8\u7f72\u65b9\u5f0f:0&nbsp;\u96c6\u4e2d\u5f0f(\u5355\u4e00\u670d\u52a1\u5668),1&nbsp;\u5206\u5e03\u5f0f(\u4e3b\u4ece\u670d\u52a1\u5668)\u3000\u3000&#8217;deploy&#8217;&nbsp;=&amp;gt;&nbsp;0, &nbsp; \u3000\u3000\/\/&nbsp;\u6570\u636e\u5e93\u8bfb\u5199\u662f\u5426\u5206\u79bb&nbsp;\u4e3b\u4ece\u5f0f\u6709\u6548\u3000\u3000&#8217;rw_separate&#8217;&nbsp;=&amp;gt;&nbsp;false, &nbsp; \u3000\u3000\/\/&nbsp;\u8bfb\u5199\u5206\u79bb\u540e&nbsp;\u4e3b\u670d\u52a1\u5668\u6570\u91cf\u3000\u3000&#8217;master_num&#8217;&nbsp;=&amp;gt;&nbsp;1, &nbsp; \u3000\u3000\/\/&nbsp;\u6307\u5b9a\u4ece\u670d\u52a1\u5668\u5e8f\u53f7\u3000\u3000&#8217;slave_no&#8217;&nbsp;=&amp;gt;&nbsp;&#8221;, &nbsp; \/\/&nbsp;\u662f\u5426\u4e25\u683c\u68c0\u67e5\u5b57\u6bb5\u662f\u5426\u5b58\u5728\u3000\u3000&#8217;fields_strict&#8217;&nbsp;=&amp;gt;&nbsp;true,]; \u767b\u5f55\u540e\u590d\u5236 2.type\u53c2\u6570\u652f\u6301\u547d\u540d\u7a7a\u95f4\u5b8c\u6574\u5b9a\u4e49\uff0c\u4e0d\u5e26\u547d\u540d\u7a7a\u95f4\u5b9a\u4e49\u7684\u8bdd\uff0c\u9ed8\u8ba4\u91c7\u7528 hinkdbconnector \u4f5c\u4e3a\u547d\u540d\u7a7a\u95f4\uff0c\u5982\u679c\u4f7f\u7528\u5e94\u7528\u81ea\u5df1\u6269\u5c55\u7684\u6570\u636e\u5e93\u9a71\u52a8\uff0c\u53ef\u4ee5\u914d\u7f6e\u4e3a\uff1a \/\/&nbsp;\u6570\u636e\u5e93\u7c7b\u578b &nbsp; &#8216;type&#8217;&nbsp;=&amp;gt;&nbsp;&#8216;orgdbMysql&#8217;, \u767b\u5f55\u540e\u590d\u5236 \u8868\u793a\u6570\u636e\u5e93\u7684\u8fde\u63a5\u5668\u91c7\u7528&nbsp;orgdbMysql \u7c7b\u4f5c\u4e3a\u6570\u636e\u5e93\u8fde\u63a5\u9a71\u52a8\uff0c\u800c\u4e0d\u662f\u9ed8\u8ba4\u7684 hinkdbconnectorMysql \u3002 3.\u6bcf\u4e2a\u6a21\u5757\u53ef\u4ee5\u8bbe\u7f6e\u72ec\u7acb\u7684\u6570\u636e\u5e93\u8fde\u63a5\u53c2\u6570\uff0c\u5e76\u4e14\u76f8\u540c\u7684\u914d\u7f6e\u53c2\u6570\u53ef\u4ee5\u65e0\u9700\u91cd\u590d\u8bbe\u7f6e\uff0c\u4f8b\u5982\u6211\u4eec\u53ef\u4ee5\u5728admin\u6a21 \u5757\u7684database.php\u914d\u7f6e\u6587\u4ef6\u4e2d\u5b9a\u4e49\uff1a return&nbsp;[ &nbsp; \u3000\u3000\/\/&nbsp;\u670d\u52a1\u5668\u5730\u5740\u3000\u3000 &nbsp; \u3000\u3000&#8217;hostname&#8217;&nbsp;=&amp;gt;&nbsp;&#8216;192.168.1.100&#8217;, &nbsp; [&hellip;]<\/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-22942","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/22942","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=22942"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/22942\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=22942"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=22942"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=22942"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}