{"id":23768,"date":"2024-11-21T09:17:27","date_gmt":"2024-11-21T01:17:27","guid":{"rendered":"https:\/\/fwq.ai\/blog\/23768\/"},"modified":"2024-11-21T09:17:27","modified_gmt":"2024-11-21T01:17:27","slug":"thinkphp3%e6%80%8e%e4%b9%88%e5%ae%9e%e7%8e%b0%e5%a2%9e%e5%88%a0%e6%94%b9%e6%9f%a5-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/23768\/","title":{"rendered":"thinkphp3\u600e\u4e48\u5b9e\u73b0\u589e\u5220\u6539\u67e5"},"content":{"rendered":"<p>\u672c\u6587\u5c06\u4e3a\u5927\u5bb6\u4ecb\u7ecdthinkphp3\u6846\u67b6\u4e0b\u7684\u589e\u5220\u6539\u67e5\u64cd\u4f5c\uff0c\u5e0c\u671b\u5bf9\u6b63\u5728\u5b66\u4e60thinkphp3\u6846\u67b6\u7684\u5f00\u53d1\u8005\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<ol>\n<li>\u589e\u52a0\u64cd\u4f5c<\/li>\n<\/ol>\n<p>\u5728ThinkPHP3\u4e2d\uff0c\u65b0\u589e\u4e00\u6761\u6570\u636e\u53ef\u4f7f\u7528M\u65b9\u6cd5\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre>$Model = M('User');\n$data['name'] = 'wuzhi';\n$data['password'] = md5('123456');\n$result = $Model-&gt;add($data);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4e0a\u8ff0\u4ee3\u7801\u610f\u601d\u662f\u5b9e\u4f8b\u5316User\u6a21\u578b\uff0c\u5e76\u4e3a\u5176\u8bbe\u7f6ename\u548cpassword\u5c5e\u6027\uff0c\u7136\u540e\u901a\u8fc7add\u65b9\u6cd5\u5c06\u6570\u636e\u63d2\u5165\u5230\u6570\u636e\u5e93\u4e2d\u3002$result\u4e3a\u63d2\u5165\u540e\u8fd4\u56de\u7684\u4e3b\u952e\u503c\u3002<\/p>\n<ol>\n<li>\u67e5\u8be2\u64cd\u4f5c<\/li>\n<\/ol>\n<p>\u67e5\u8be2\u5355\u4e2a\u6570\u636e\u7528find\u65b9\u6cd5\uff0c\u67e5\u8be2\u591a\u4e2a\u6570\u636e\u7528select\u65b9\u6cd5\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre>$Model = M('User');\n$condition['id'] = 1;\n$result = $Model-&gt;where($condition)-&gt;find();<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4e0a\u8ff0\u4ee3\u7801\u610f\u601d\u4e3a\u67e5\u8be2id\u4e3a1\u7684\u7528\u6237\u6570\u636e\u5e76\u8fd4\u56de\u7ed3\u679c\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>$Model = M('User');\n$condition['id'] = array('between',array(1,10));\n$result = $Model-&gt;where($condition)-&gt;select();<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4e0a\u8ff0\u4ee3\u7801\u4e3a\u67e5\u8be2id\u57281-10\u4e4b\u95f4\u7684\u7528\u6237\u6570\u636e\u5e76\u8fd4\u56de\u7ed3\u679c\u3002<\/p>\n<ol>\n<li>\u4fee\u6539\u64cd\u4f5c<\/li>\n<\/ol>\n<p>\u4f7f\u7528save\u65b9\u6cd5\u5bf9\u5df2\u6709\u6570\u636e\u8fdb\u884c\u4fee\u6539\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre>$Model = M('User');\n$condition['id'] = 1;\n$data['name'] = 'lisi';\n$data['password'] = md5('654321');\n$result = $Model-&gt;where($condition)-&gt;save($data);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4e0a\u8ff0\u4ee3\u7801\u5c06id\u4e3a1\u7684\u7528\u6237\u7684name\u548cpassword\u4fee\u6539\u4e3a\u4e86lisi\u548c654321\u3002<\/p>\n<ol>\n<li>\u5220\u9664\u64cd\u4f5c<\/li>\n<\/ol>\n<p>\u4f7f\u7528delete\u65b9\u6cd5\u5220\u9664\u6570\u636e\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre>$Model = M('User');\n$condition['id'] = 1;\n$result = $Model-&gt;where($condition)-&gt;delete();<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4e0a\u8ff0\u4ee3\u7801\u5c06id\u4e3a1\u7684\u7528\u6237\u6570\u636e\u8fdb\u884c\u5220\u9664\u64cd\u4f5c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fThinkPHP3\u6846\u67b6\u4e0b\u7684\u589e\u5220\u6539\u67e5\u64cd\u4f5c\u7684\u57fa\u672c\u4ecb\u7ecd\u3002\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u7075\u6d3b\u8fd0\u7528\u4ee5\u4e0a\u65b9\u6cd5\u6765\u5b9e\u73b0\u5404\u79cd\u529f\u80fd\u3002\u5e0c\u671b\u672c\u6587\u80fd\u591f\u5e2e\u52a9\u5230\u5927\u5bb6\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fthinkphp3\u600e\u4e48\u5b9e\u73b0\u589e\u5220\u6539\u67e5\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>\u672c\u6587\u5c06\u4e3a\u5927\u5bb6\u4ecb\u7ecdthinkphp3\u6846\u67b6\u4e0b\u7684\u589e\u5220\u6539\u67e5\u64cd\u4f5c\uff0c\u5e0c\u671b\u5bf9\u6b63\u5728\u5b66\u4e60thinkphp3\u6846\u67b6\u7684\u5f00\u53d1\u8005\u6709\u6240\u5e2e\u52a9\u3002 \u589e\u52a0\u64cd\u4f5c \u5728ThinkPHP3\u4e2d\uff0c\u65b0\u589e\u4e00\u6761\u6570\u636e\u53ef\u4f7f\u7528M\u65b9\u6cd5\uff0c\u4f8b\u5982\uff1a $Model = M(&#8216;User&#8217;); $data[&#8216;name&#8217;] = &#8216;wuzhi&#8217;; $data[&#8216;password&#8217;] = md5(&#8216;123456&#8217;); $result = $Model-&gt;add($data); \u767b\u5f55\u540e\u590d\u5236 \u4e0a\u8ff0\u4ee3\u7801\u610f\u601d\u662f\u5b9e\u4f8b\u5316User\u6a21\u578b\uff0c\u5e76\u4e3a\u5176\u8bbe\u7f6ename\u548cpassword\u5c5e\u6027\uff0c\u7136\u540e\u901a\u8fc7add\u65b9\u6cd5\u5c06\u6570\u636e\u63d2\u5165\u5230\u6570\u636e\u5e93\u4e2d\u3002$result\u4e3a\u63d2\u5165\u540e\u8fd4\u56de\u7684\u4e3b\u952e\u503c\u3002 \u67e5\u8be2\u64cd\u4f5c \u67e5\u8be2\u5355\u4e2a\u6570\u636e\u7528find\u65b9\u6cd5\uff0c\u67e5\u8be2\u591a\u4e2a\u6570\u636e\u7528select\u65b9\u6cd5\uff0c\u4f8b\u5982\uff1a $Model = M(&#8216;User&#8217;); $condition[&#8216;id&#8217;] = 1; $result = $Model-&gt;where($condition)-&gt;find(); \u767b\u5f55\u540e\u590d\u5236 \u4e0a\u8ff0\u4ee3\u7801\u610f\u601d\u4e3a\u67e5\u8be2id\u4e3a1\u7684\u7528\u6237\u6570\u636e\u5e76\u8fd4\u56de\u7ed3\u679c\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b $Model = M(&#8216;User&#8217;); $condition[&#8216;id&#8217;] = array(&#8216;between&#8217;,array(1,10)); $result = $Model-&gt;where($condition)-&gt;select(); \u767b\u5f55\u540e\u590d\u5236 \u4e0a\u8ff0\u4ee3\u7801\u4e3a\u67e5\u8be2id\u57281-10\u4e4b\u95f4\u7684\u7528\u6237\u6570\u636e\u5e76\u8fd4\u56de\u7ed3\u679c\u3002 \u4fee\u6539\u64cd\u4f5c \u4f7f\u7528save\u65b9\u6cd5\u5bf9\u5df2\u6709\u6570\u636e\u8fdb\u884c\u4fee\u6539\uff0c\u4f8b\u5982\uff1a $Model = M(&#8216;User&#8217;); $condition[&#8216;id&#8217;] = 1; $data[&#8216;name&#8217;] = &#8216;lisi&#8217;; $data[&#8216;password&#8217;] = [&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-23768","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/23768","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=23768"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/23768\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=23768"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=23768"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=23768"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}