{"id":23632,"date":"2024-11-21T09:28:38","date_gmt":"2024-11-21T01:28:38","guid":{"rendered":"https:\/\/fwq.ai\/blog\/23632\/"},"modified":"2024-11-21T09:28:38","modified_gmt":"2024-11-21T01:28:38","slug":"%e5%88%a9%e7%94%a8thinkphp6%e5%ae%9e%e7%8e%b0%e5%a4%9a%e6%9d%a1%e4%bb%b6%e6%9f%a5%e8%af%a2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/23632\/","title":{"rendered":"\u5229\u7528ThinkPHP6\u5b9e\u73b0\u591a\u6761\u4ef6\u67e5\u8be2"},"content":{"rendered":"<p>\u968f\u7740\u4e92\u8054\u7f51\u6280\u672f\u7684\u4e0d\u65ad\u53d1\u5c55\uff0c\u4f01\u4e1a\u9700\u8981\u66f4\u52a0\u667a\u80fd\u7684\u4fe1\u606f\u5316\u7cfb\u7edf\u8fdb\u884c\u7ba1\u7406\u548c\u53d1\u5c55\u3002\u800c\u4e00\u4e2a\u597d\u7684\u4fe1\u606f\u5316\u7cfb\u7edf\u4e0d\u4ec5\u8981\u80fd\u591f\u5b9e\u73b0\u57fa\u672c\u7684\u6570\u636e\u5b58\u50a8\u548c\u5904\u7406\uff0c\u8fd8\u9700\u8981\u80fd\u591f\u63d0\u4f9b\u591a\u79cd\u67e5\u8be2\u6761\u4ef6\uff0c\u4f7f\u5f97\u7528\u6237\u80fd\u591f\u66f4\u52a0\u5feb\u901f\u51c6\u786e\u5730\u83b7\u53d6\u6240\u9700\u7684\u6570\u636e\u3002\u672c\u6587\u5c06\u7b80\u8981\u4ecb\u7ecd\u5982\u4f55\u5229\u75286\u6846\u67b6\u5b9e\u73b0\u591a\u6761\u4ef6\u67e5\u8be2\u3002<\/p>\n<p>ThinkPHP6\u662f\u4e00\u6b3e\u8f7b\u91cf\u7ea7\u3001\u9ad8\u6548\u6027\u3001\u7075\u6d3b\u6027\u5f88\u9ad8\u7684PHP\u6846\u67b6\uff0c\u5b83\u91c7\u7528MVC\u8bbe\u8ba1\u6a21\u5f0f\u548c\u6a21\u5757\u5316\u5f00\u53d1\u601d\u60f3\uff0c\u5728\u5f00\u53d1\u8005\u4e2d\u95f4\u5b58\u5728\u6bd4\u8f83\u9ad8\u7684\u4f7f\u7528\u7387\u3002ThinkPHP6\u7684\u6570\u636e\u5e93\u64cd\u4f5c\u975e\u5e38\u7b80\u5355\uff0c\u652f\u6301\u4e00\u7cfb\u5217\u7684CURD\u64cd\u4f5c\uff0c\u9002\u7528\u4e8e\u5f00\u53d1\u5404\u79cd\u7c7b\u578b\u7684\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5728ThinkPHP6\u4e2d\u521b\u5efa\u63a7\u5236\u5668\u3001\u6a21\u578b\u548c\u89c6\u56fe\u3002\u5728\u63a7\u5236\u5668\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u5b9a\u4e49\u591a\u4e2a\u53d8\u91cf\u7528\u4e8e\u63a5\u6536\u7528\u6237\u63d0\u4f9b\u7684\u67e5\u8be2\u6761\u4ef6\uff0c\u4ee5\u53ca\u8c03\u7528\u6a21\u578b\u4e2d\u5b9a\u4e49\u7684\u67e5\u8be2\u65b9\u6cd5\u3002\u6a21\u578b\u4e2d\u9700\u8981\u5b9a\u4e49\u4e00\u4e2a\u591a\u6761\u4ef6\u67e5\u8be2\u7684\u65b9\u6cd5\uff0c\u8be5\u65b9\u6cd5\u63a5\u6536\u591a\u4e2a\u53c2\u6570\uff0c\u6bcf\u4e2a\u53c2\u6570\u4ee3\u8868\u4e00\u79cd\u67e5\u8be2\u6761\u4ef6\u3002\u5728\u89c6\u56fe\u4e2d\uff0c\u9700\u8981\u8bbe\u7f6e\u8868\u5355\u5143\u7d20\uff0c\u7528\u4e8e\u83b7\u53d6\u7528\u6237\u8f93\u5165\u7684\u67e5\u8be2\u6761\u4ef6\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u4ee3\u7801\u5b9e\u73b0\u6a21\u578b\u4e2d\u7684\u591a\u6761\u4ef6\u67e5\u8be2\u65b9\u6cd5\uff1a<\/p>\n<pre>public function query($cond1, $cond2, $cond3) \n{\n    $query = $this-&amp;gt;where('cond1', $cond1)\n                  -&amp;gt;where('cond2', $cond2)\n                  -&amp;gt;where('cond3', $cond3);\n    $result = $query-&amp;gt;select();\n\n    return $result;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728\u63a7\u5236\u5668\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u4ee3\u7801\u8fdb\u884c\u8bbe\u7f6e\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>public function search() \n{\n    $cond1 = input('param.cond1');\n    $cond2 = input('param.cond2');\n    $cond3 = input('param.cond3');\n    $model = new Model;\n    $result = $model-&amp;gt;query($cond1, $cond2, $cond3);\n    $this-&amp;gt;assign('result', $result);\n    return $this-&amp;gt;fetch();\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728\u89c6\u56fe\u4e2d\uff0c\u9700\u8981\u8bbe\u7f6e\u8868\u5355\u5143\u7d20\uff0c\u63a5\u6536\u7528\u6237\u8f93\u5165\u7684\u67e5\u8be2\u6761\u4ef6\uff0c\u5e76\u5c06\u5176\u4f20\u9012\u7ed9\u63a7\u5236\u5668\u8fdb\u884c\u64cd\u4f5c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff1a<\/p>\n<pre><\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u901a\u8fc7\u4e0a\u8ff0\u4ee3\u7801\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5b9e\u73b0\u57fa\u672c\u7684\u591a\u6761\u4ef6\u67e5\u8be2\u64cd\u4f5c\u4e86\u3002\u5728\u5b9e\u9645\u4f7f\u7528\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u9700\u6c42\uff0c\u8fdb\u4e00\u6b65\u4f18\u5316\u67e5\u8be2\u6548\u7387\uff0c\u63d0\u4f9b\u66f4\u52a0\u667a\u80fd\u7684\u67e5\u8be2\u65b9\u5f0f\u3002<\/p>\n<p>\u6700\u540e\u503c\u5f97\u6ce8\u610f\u7684\u4e00\u70b9\u662f\uff1a\u5728\u4f7f\u7528\u591a\u6761\u4ef6\u67e5\u8be2\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u8f93\u5165\u7684\u683c\u5f0f\u548c\u7c7b\u578b\uff0c\u4ee5\u907f\u514d\u6570\u636e\u5e93\u6ce8\u5165\u7b49\u5b89\u5168\u95ee\u9898\u3002\u540c\u65f6\uff0c\u4e3a\u4e86\u63d0\u9ad8\u67e5\u8be2\u6548\u7387\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u6570\u636e\u5e93\u4e2d\u8bbe\u7f6e\u4e00\u4e9b\u53c2\u6570\uff0c\u6bd4\u5982\u6dfb\u52a0\u7d22\u5f15\u7b49\u3002\u8fd9\u4e9b\u90fd\u662f\u503c\u5f97\u601d\u8003\u548c\u5b66\u4e60\u7684\u95ee\u9898\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5229\u7528ThinkPHP6\u5b9e\u73b0\u591a\u6761\u4ef6\u67e5\u8be2\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>\u968f\u7740\u4e92\u8054\u7f51\u6280\u672f\u7684\u4e0d\u65ad\u53d1\u5c55\uff0c\u4f01\u4e1a\u9700\u8981\u66f4\u52a0\u667a\u80fd\u7684\u4fe1\u606f\u5316\u7cfb\u7edf\u8fdb\u884c\u7ba1\u7406\u548c\u53d1\u5c55\u3002\u800c\u4e00\u4e2a\u597d\u7684\u4fe1\u606f\u5316\u7cfb\u7edf\u4e0d\u4ec5\u8981\u80fd\u591f\u5b9e\u73b0\u57fa\u672c\u7684\u6570\u636e\u5b58\u50a8\u548c\u5904\u7406\uff0c\u8fd8\u9700\u8981\u80fd\u591f\u63d0\u4f9b\u591a\u79cd\u67e5\u8be2\u6761\u4ef6\uff0c\u4f7f\u5f97\u7528\u6237\u80fd\u591f\u66f4\u52a0\u5feb\u901f\u51c6\u786e\u5730\u83b7\u53d6\u6240\u9700\u7684\u6570\u636e\u3002\u672c\u6587\u5c06\u7b80\u8981\u4ecb\u7ecd\u5982\u4f55\u5229\u75286\u6846\u67b6\u5b9e\u73b0\u591a\u6761\u4ef6\u67e5\u8be2\u3002 ThinkPHP6\u662f\u4e00\u6b3e\u8f7b\u91cf\u7ea7\u3001\u9ad8\u6548\u6027\u3001\u7075\u6d3b\u6027\u5f88\u9ad8\u7684PHP\u6846\u67b6\uff0c\u5b83\u91c7\u7528MVC\u8bbe\u8ba1\u6a21\u5f0f\u548c\u6a21\u5757\u5316\u5f00\u53d1\u601d\u60f3\uff0c\u5728\u5f00\u53d1\u8005\u4e2d\u95f4\u5b58\u5728\u6bd4\u8f83\u9ad8\u7684\u4f7f\u7528\u7387\u3002ThinkPHP6\u7684\u6570\u636e\u5e93\u64cd\u4f5c\u975e\u5e38\u7b80\u5355\uff0c\u652f\u6301\u4e00\u7cfb\u5217\u7684CURD\u64cd\u4f5c\uff0c\u9002\u7528\u4e8e\u5f00\u53d1\u5404\u79cd\u7c7b\u578b\u7684\u5e94\u7528\u7a0b\u5e8f\u3002 \u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5728ThinkPHP6\u4e2d\u521b\u5efa\u63a7\u5236\u5668\u3001\u6a21\u578b\u548c\u89c6\u56fe\u3002\u5728\u63a7\u5236\u5668\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u5b9a\u4e49\u591a\u4e2a\u53d8\u91cf\u7528\u4e8e\u63a5\u6536\u7528\u6237\u63d0\u4f9b\u7684\u67e5\u8be2\u6761\u4ef6\uff0c\u4ee5\u53ca\u8c03\u7528\u6a21\u578b\u4e2d\u5b9a\u4e49\u7684\u67e5\u8be2\u65b9\u6cd5\u3002\u6a21\u578b\u4e2d\u9700\u8981\u5b9a\u4e49\u4e00\u4e2a\u591a\u6761\u4ef6\u67e5\u8be2\u7684\u65b9\u6cd5\uff0c\u8be5\u65b9\u6cd5\u63a5\u6536\u591a\u4e2a\u53c2\u6570\uff0c\u6bcf\u4e2a\u53c2\u6570\u4ee3\u8868\u4e00\u79cd\u67e5\u8be2\u6761\u4ef6\u3002\u5728\u89c6\u56fe\u4e2d\uff0c\u9700\u8981\u8bbe\u7f6e\u8868\u5355\u5143\u7d20\uff0c\u7528\u4e8e\u83b7\u53d6\u7528\u6237\u8f93\u5165\u7684\u67e5\u8be2\u6761\u4ef6\u3002 \u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u4ee3\u7801\u5b9e\u73b0\u6a21\u578b\u4e2d\u7684\u591a\u6761\u4ef6\u67e5\u8be2\u65b9\u6cd5\uff1a public function query($cond1, $cond2, $cond3) { $query = $this-&amp;gt;where(&#8216;cond1&#8217;, $cond1) -&amp;gt;where(&#8216;cond2&#8217;, $cond2) -&amp;gt;where(&#8216;cond3&#8217;, $cond3); $result = $query-&amp;gt;select(); return $result; } \u767b\u5f55\u540e\u590d\u5236 \u5728\u63a7\u5236\u5668\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u4ee3\u7801\u8fdb\u884c\u8bbe\u7f6e\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b public function search() { $cond1 = input(&#8216;param.cond1&#8217;); $cond2 = input(&#8216;param.cond2&#8217;); $cond3 = input(&#8216;param.cond3&#8217;); $model = new Model; $result = $model-&amp;gt;query($cond1, $cond2, $cond3); $this-&amp;gt;assign(&#8216;result&#8217;, $result); return $this-&amp;gt;fetch(); } \u767b\u5f55\u540e\u590d\u5236 [&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-23632","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/23632","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=23632"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/23632\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=23632"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=23632"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=23632"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}