{"id":22780,"date":"2024-11-21T08:32:24","date_gmt":"2024-11-21T00:32:24","guid":{"rendered":"https:\/\/fwq.ai\/blog\/22780\/"},"modified":"2024-11-21T08:32:24","modified_gmt":"2024-11-21T00:32:24","slug":"thinkphp%e5%8e%bb%e6%8e%89%e9%bb%98%e8%ae%a4%e9%99%90%e5%88%b6","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/22780\/","title":{"rendered":"thinkphp\u53bb\u6389\u9ed8\u8ba4\u9650\u5236"},"content":{"rendered":"<p>\u5728\u4f7f\u7528thinkphp\u6846\u67b6\u5f00\u53d1\u9879\u76ee\u65f6\uff0c\u6211\u4eec\u53ef\u80fd\u4f1a\u53d1\u73b0\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u6846\u67b6\u4f1a\u5bf9\u4e0a\u4f20\u6587\u4ef6\u5927\u5c0f\u3001\u8868\u5355\u63d0\u4ea4\u6570\u636e\u5927\u5c0f\u4ee5\u53casql\u67e5\u8be2\u7ed3\u679c\u6761\u6570\u7b49\u8fdb\u884c\u9650\u5236\uff0c\u8fd9\u5bf9\u4e8e\u4e00\u4e9b\u9700\u8981\u4e0a\u4f20\u5927\u6587\u4ef6\u6216\u8005\u67e5\u8be2\u5927\u6570\u636e\u91cf\u7684\u9879\u76ee\u6765\u8bf4\u4f1a\u5e26\u6765\u5f88\u5927\u7684\u56f0\u6270\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u9700\u8981\u5bf9\u8fd9\u4e9b\u9ed8\u8ba4\u9650\u5236\u8fdb\u884c\u4fee\u6539\u548c\u53bb\u9664\u3002<\/p>\n<ol>\n<li>\u53bb\u9664\u4e0a\u4f20\u6587\u4ef6\u5927\u5c0f\u9650\u5236<\/li>\n<\/ol>\n<p>\u5728thinkphp\u6846\u67b6\u4e2d\uff0c\u4e0a\u4f20\u6587\u4ef6\u5927\u5c0f\u7684\u9650\u5236\u662f\u7531php.ini\u4e2d\u7684upload_max_filesize\u548cpost_max_size\u6765\u5b9e\u73b0\u7684\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u4fee\u6539php.ini\u6587\u4ef6\u4e2d\u7684\u8fd9\u4e24\u4e2a\u914d\u7f6e\u9879\u3002<\/p>\n<p>\u9996\u5148\uff0c\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165php &#8211;ini\uff0c\u53ef\u4ee5\u67e5\u770bphp.ini\u6587\u4ef6\u7684\u8def\u5f84\u3002\u627e\u5230\u8be5\u6587\u4ef6\u5e76\u6253\u5f00\uff0c\u7136\u540e\u8fdb\u884c\u5982\u4e0b\u4fee\u6539\uff1a<\/p>\n<p>upload_max_filesize = 100M<br \/>post_max_size = 100M<\/p>\n<p>\u5176\u4e2d100M\u53ef\u4ee5\u6839\u636e\u9879\u76ee\u9700\u8981\u81ea\u884c\u8c03\u6574\u3002\u4fee\u6539\u5b8c\u6210\u540e\uff0c\u4fdd\u5b58\u5e76\u91cd\u542fApache\u6216\u8005Nginx\u670d\u52a1\u5668\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<ol>\n<li>\u53bb\u9664\u8868\u5355\u63d0\u4ea4\u6570\u636e\u5927\u5c0f\u9650\u5236<\/li>\n<\/ol>\n<p>\u5728thinkphp\u6846\u67b6\u4e2d\uff0c\u8868\u5355\u63d0\u4ea4\u6570\u636e\u5927\u5c0f\u7684\u9650\u5236\u662f\u7531php.ini\u4e2d\u7684post_max_size\u548cmemory_limit\u6765\u5b9e\u73b0\u7684\uff0c\u540c\u6837\u9700\u8981\u8fdb\u884c\u4fee\u6539\u3002\u5728php.ini\u6587\u4ef6\u4e2d\u627e\u5230\u8fd9\u4e24\u4e2a\u914d\u7f6e\u9879\uff0c\u5e76\u8fdb\u884c\u5982\u4e0b\u4fee\u6539\uff1a<\/p>\n<p>post_max_size = 100M<br \/>memory_limit = 128M<\/p>\n<p>\u5176\u4e2d100M\u53ef\u4ee5\u6839\u636e\u9879\u76ee\u9700\u8981\u81ea\u884c\u8c03\u6574\u3002\u4fee\u6539\u5b8c\u6210\u540e\uff0c\u4fdd\u5b58\u5e76\u91cd\u542fApache\u6216\u8005Nginx\u670d\u52a1\u5668\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<ol>\n<li>\u53bb\u9664sql\u67e5\u8be2\u7ed3\u679c\u6761\u6570\u9650\u5236<\/li>\n<\/ol>\n<p>\u5728thinkphp\u6846\u67b6\u4e2d\uff0csql\u67e5\u8be2\u7ed3\u679c\u6761\u6570\u7684\u9650\u5236\u662f\u7531\u6846\u67b6\u81ea\u8eab\u8bbe\u5b9a\u7684\uff0c\u56e0\u6b64\u9700\u8981\u5bf9\u6846\u67b6\u4ee3\u7801\u8fdb\u884c\u4fee\u6539\u3002<\/p>\n<p>\u5728thinkphp\u6846\u67b6\u7684\u6838\u5fc3\u4ee3\u7801\u6587\u4ef6ThinkPHPDbDriverPdo.php\u4e2d\uff0c\u53ef\u4ee5\u627e\u5230\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<p>if (isset($options[&#8216;limit&#8217;])) {<\/p>\n<pre>$limit = is_numeric($options['limit']) ? $options['limit'] : 100000;\n$this-&amp;gt;_queryStr .= ' LIMIT ' . $limit;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>}<\/p>\n<p>\u5176\u4e2d100000\u5373\u4e3a\u9ed8\u8ba4\u7684\u67e5\u8be2\u7ed3\u679c\u6761\u6570\u9650\u5236\u3002\u6211\u4eec\u53ef\u4ee5\u5c06\u5176\u4fee\u6539\u4e3a\u66f4\u5927\u7684\u6570\u503c\u6216\u8005\u6539\u4e3a0\u8868\u793a\u4e0d\u9650\u5236\u6761\u6570\u3002\u4fee\u6539\u5b8c\u6210\u540e\uff0c\u4fdd\u5b58\u5e76\u91cd\u65b0\u8fd0\u884c\u9879\u76ee\u5373\u53ef\u3002<\/p>\n<p>\u603b\u7ed3<\/p>\n<p>\u901a\u8fc7\u5bf9php.ini\u914d\u7f6e\u6587\u4ef6\u4ee5\u53cathinkphp\u6846\u67b6\u4ee3\u7801\u7684\u4fee\u6539\uff0c\u6211\u4eec\u53ef\u4ee5\u53bb\u9664\u9ed8\u8ba4\u9650\u5236\uff0c\u89e3\u51b3\u4e00\u4e9b\u4e0a\u4f20\u5927\u6587\u4ef6\u6216\u8005\u67e5\u8be2\u5927\u6570\u636e\u91cf\u7684\u9879\u76ee\u4e2d\u7684\u56f0\u6270\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5728\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u65f6\uff0c\u8981\u6839\u636e\u5177\u4f53\u9700\u6c42\u8fdb\u884c\u8c03\u6574\uff0c\u4e0d\u8981\u8bbe\u7f6e\u8fc7\u4e8e\u5de8\u5927\u7684\u6570\u503c\u5bfc\u81f4\u670d\u52a1\u5668\u8d1f\u62c5\u8fc7\u5927\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fthinkphp\u53bb\u6389\u9ed8\u8ba4\u9650\u5236\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>\u5728\u4f7f\u7528thinkphp\u6846\u67b6\u5f00\u53d1\u9879\u76ee\u65f6\uff0c\u6211\u4eec\u53ef\u80fd\u4f1a\u53d1\u73b0\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u6846\u67b6\u4f1a\u5bf9\u4e0a\u4f20\u6587\u4ef6\u5927\u5c0f\u3001\u8868\u5355\u63d0\u4ea4\u6570\u636e\u5927\u5c0f\u4ee5\u53casql\u67e5\u8be2\u7ed3\u679c\u6761\u6570\u7b49\u8fdb\u884c\u9650\u5236\uff0c\u8fd9\u5bf9\u4e8e\u4e00\u4e9b\u9700\u8981\u4e0a\u4f20\u5927\u6587\u4ef6\u6216\u8005\u67e5\u8be2\u5927\u6570\u636e\u91cf\u7684\u9879\u76ee\u6765\u8bf4\u4f1a\u5e26\u6765\u5f88\u5927\u7684\u56f0\u6270\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u9700\u8981\u5bf9\u8fd9\u4e9b\u9ed8\u8ba4\u9650\u5236\u8fdb\u884c\u4fee\u6539\u548c\u53bb\u9664\u3002 \u53bb\u9664\u4e0a\u4f20\u6587\u4ef6\u5927\u5c0f\u9650\u5236 \u5728thinkphp\u6846\u67b6\u4e2d\uff0c\u4e0a\u4f20\u6587\u4ef6\u5927\u5c0f\u7684\u9650\u5236\u662f\u7531php.ini\u4e2d\u7684upload_max_filesize\u548cpost_max_size\u6765\u5b9e\u73b0\u7684\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u4fee\u6539php.ini\u6587\u4ef6\u4e2d\u7684\u8fd9\u4e24\u4e2a\u914d\u7f6e\u9879\u3002 \u9996\u5148\uff0c\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165php &#8211;ini\uff0c\u53ef\u4ee5\u67e5\u770bphp.ini\u6587\u4ef6\u7684\u8def\u5f84\u3002\u627e\u5230\u8be5\u6587\u4ef6\u5e76\u6253\u5f00\uff0c\u7136\u540e\u8fdb\u884c\u5982\u4e0b\u4fee\u6539\uff1a upload_max_filesize = 100Mpost_max_size = 100M \u5176\u4e2d100M\u53ef\u4ee5\u6839\u636e\u9879\u76ee\u9700\u8981\u81ea\u884c\u8c03\u6574\u3002\u4fee\u6539\u5b8c\u6210\u540e\uff0c\u4fdd\u5b58\u5e76\u91cd\u542fApache\u6216\u8005Nginx\u670d\u52a1\u5668\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u53bb\u9664\u8868\u5355\u63d0\u4ea4\u6570\u636e\u5927\u5c0f\u9650\u5236 \u5728thinkphp\u6846\u67b6\u4e2d\uff0c\u8868\u5355\u63d0\u4ea4\u6570\u636e\u5927\u5c0f\u7684\u9650\u5236\u662f\u7531php.ini\u4e2d\u7684post_max_size\u548cmemory_limit\u6765\u5b9e\u73b0\u7684\uff0c\u540c\u6837\u9700\u8981\u8fdb\u884c\u4fee\u6539\u3002\u5728php.ini\u6587\u4ef6\u4e2d\u627e\u5230\u8fd9\u4e24\u4e2a\u914d\u7f6e\u9879\uff0c\u5e76\u8fdb\u884c\u5982\u4e0b\u4fee\u6539\uff1a post_max_size = 100Mmemory_limit = 128M \u5176\u4e2d100M\u53ef\u4ee5\u6839\u636e\u9879\u76ee\u9700\u8981\u81ea\u884c\u8c03\u6574\u3002\u4fee\u6539\u5b8c\u6210\u540e\uff0c\u4fdd\u5b58\u5e76\u91cd\u542fApache\u6216\u8005Nginx\u670d\u52a1\u5668\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u53bb\u9664sql\u67e5\u8be2\u7ed3\u679c\u6761\u6570\u9650\u5236 \u5728thinkphp\u6846\u67b6\u4e2d\uff0csql\u67e5\u8be2\u7ed3\u679c\u6761\u6570\u7684\u9650\u5236\u662f\u7531\u6846\u67b6\u81ea\u8eab\u8bbe\u5b9a\u7684\uff0c\u56e0\u6b64\u9700\u8981\u5bf9\u6846\u67b6\u4ee3\u7801\u8fdb\u884c\u4fee\u6539\u3002 \u5728thinkphp\u6846\u67b6\u7684\u6838\u5fc3\u4ee3\u7801\u6587\u4ef6ThinkPHPDbDriverPdo.php\u4e2d\uff0c\u53ef\u4ee5\u627e\u5230\u4ee5\u4e0b\u4ee3\u7801\uff1a if (isset($options[&#8216;limit&#8217;])) { $limit = is_numeric($options[&#8216;limit&#8217;]) ? $options[&#8216;limit&#8217;] : 100000; $this-&amp;gt;_queryStr .= &#8216; LIMIT &#8216; . $limit; \u767b\u5f55\u540e\u590d\u5236 } \u5176\u4e2d100000\u5373\u4e3a\u9ed8\u8ba4\u7684\u67e5\u8be2\u7ed3\u679c\u6761\u6570\u9650\u5236\u3002\u6211\u4eec\u53ef\u4ee5\u5c06\u5176\u4fee\u6539\u4e3a\u66f4\u5927\u7684\u6570\u503c\u6216\u8005\u6539\u4e3a0\u8868\u793a\u4e0d\u9650\u5236\u6761\u6570\u3002\u4fee\u6539\u5b8c\u6210\u540e\uff0c\u4fdd\u5b58\u5e76\u91cd\u65b0\u8fd0\u884c\u9879\u76ee\u5373\u53ef\u3002 \u603b\u7ed3 \u901a\u8fc7\u5bf9php.ini\u914d\u7f6e\u6587\u4ef6\u4ee5\u53cathinkphp\u6846\u67b6\u4ee3\u7801\u7684\u4fee\u6539\uff0c\u6211\u4eec\u53ef\u4ee5\u53bb\u9664\u9ed8\u8ba4\u9650\u5236\uff0c\u89e3\u51b3\u4e00\u4e9b\u4e0a\u4f20\u5927\u6587\u4ef6\u6216\u8005\u67e5\u8be2\u5927\u6570\u636e\u91cf\u7684\u9879\u76ee\u4e2d\u7684\u56f0\u6270\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5728\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u65f6\uff0c\u8981\u6839\u636e\u5177\u4f53\u9700\u6c42\u8fdb\u884c\u8c03\u6574\uff0c\u4e0d\u8981\u8bbe\u7f6e\u8fc7\u4e8e\u5de8\u5927\u7684\u6570\u503c\u5bfc\u81f4\u670d\u52a1\u5668\u8d1f\u62c5\u8fc7\u5927\u3002 \u4ee5\u4e0a\u5c31\u662fthinkphp\u53bb\u6389\u9ed8\u8ba4\u9650\u5236\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\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-22780","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/22780","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=22780"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/22780\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=22780"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=22780"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=22780"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}