{"id":156,"date":"2018-09-19T18:38:33","date_gmt":"2018-09-19T10:38:33","guid":{"rendered":"https:\/\/wp.dj47.top\/?p=156"},"modified":"2021-10-20T16:19:03","modified_gmt":"2021-10-20T08:19:03","slug":"thinkphp%e5%85%b3%e4%ba%8e%e6%96%87%e7%ab%a0%e6%b7%bb%e5%8a%a0%e7%9a%84%e6%97%b6%e9%97%b4%e7%ad%9b%e9%80%89%e6%9f%a5%e8%af%a2%ef%bc%88%e4%bb%8a%e5%a4%a9%ef%bc%8c%e4%b8%80%e5%91%a8%e5%86%85%ef%bc%8c","status":"publish","type":"post","link":"https:\/\/www.djlog.cn\/?p=156","title":{"rendered":"ThinkPHP\u5173\u4e8e\u6587\u7ae0\u6dfb\u52a0\u7684\u65f6\u95f4\u7b5b\u9009\u67e5\u8be2\uff08\u4eca\u5929\uff0c\u4e00\u5468\u5185\uff0c\u4e00\u4e2a\u6708\u5185\uff0c\u4e09\u4e2a\u6708\u5185\uff0c\u5927\u4e8e\u4e09\u4e2a\u6708\uff09"},"content":{"rendered":"<p style=\"box-sizing: border-box; margin: 0px 0px 16px; outline: 0px; padding: 0px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun; background-color: #ffffff;\"><span style=\"box-sizing: border-box; outline: 0px; word-break: break-all; font-size: 12px;\"><span style=\"box-sizing: border-box; outline: 0px; font-weight: bold; word-break: break-all;\">\u6570\u636e\u8868\u4e2d\u6587\u7ae0\u6dfb\u52a0\u7684\u65f6\u95f4\u5b57\u6bb5\u5b58\u50a8\u6570\u636e\u7c7b\u578b\u4e3a\uff1adatetime<\/span><br style=\"box-sizing: border-box; outline: 0px; word-break: break-all;\" \/><\/span><\/p>\n<p style=\"box-sizing: border-box; margin: 0px 0px 16px; outline: 0px; padding: 0px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun; background-color: #ffffff;\"><span style=\"box-sizing: border-box; outline: 0px; word-break: break-all; font-size: 12px;\">\u6a21\u677f\u9875\u9762<span style=\"box-sizing: border-box; outline: 0px; word-break: break-all; color: #ff0000;\"><span style=\"box-sizing: border-box; outline: 0px; font-weight: bold; word-break: break-all;\">index.html<\/span><\/span><\/span><\/p>\n<p style=\"box-sizing: border-box; margin: 0px 0px 16px; outline: 0px; padding: 0px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun; background-color: #ffffff;\"><span style=\"box-sizing: border-box; outline: 0px; word-break: break-all; font-size: 12px;\">\u521b\u5efa\u4e00\u4e2a\u8868\u5355\uff0c\u4ee5\u4fbf\u9009\u62e9\u7b5b\u9009\u67e5\u8be2<\/span><\/p>\n<pre class=\"language-html\"><code>&lt;html&gt;\r\n&lt;head&gt;\r\n    &lt;script&gt;\r\n        $(function() {\r\n            \/\/\u5224\u65ad\u63d0\u4ea4\u67e5\u8be2\r\n            $(\"select[name='add_time']\").val(\"{$add_time}\"); \/\/\u63a5\u6536\u63a7\u5236\u5668\u7684\u6a21\u677f\u8d4b\u503c\r\n            $(\"#choice\").submit(function() {\r\n                if ($(\"select[name='add_time']\").val() == 999) { \/\/\u672a\u9009\u62e9\u65f6\u7981\u6b62\u8868\u5355\u63d0\u4ea4\r\n                    alert(\"\u8bf7\u9009\u62e9\u67e5\u8be2\u65f6\u95f4\uff01\");\r\n                    return false;\r\n                }\r\n            });\r\n\r\n        });\r\n    &lt;\/script&gt;\r\n&lt;\/head&gt;\r\n\r\n&lt;body&gt;\r\n    &lt;form action=\"{:U('Index\/search')}\" method=\"get\" id=\"choice\"&gt;\r\n        &lt;label&gt;\u6309\u65f6\u95f4\u67e5\u8be2\uff1a&lt;\/label&gt;\r\n        &lt;select name=\"add_time\"&gt;\r\n            &lt;option value=\"999\" style=\"color:#ccc\"&gt;===\u8bf7\u9009\u62e9\u67e5\u8be2\u65f6\u95f4===&lt;\/option&gt;\r\n            &lt;option value=\"0\"&gt;\u4eca\u5929&lt;\/option&gt;\r\n            &lt;option value=\"1\"&gt;\u4e00\u5468\u4e4b\u5185&lt;\/option&gt;\r\n            &lt;option value=\"2\"&gt;\u4e00\u4e2a\u6708\u4e4b\u5185&lt;\/option&gt;\r\n            &lt;option value=\"3\"&gt;\u4e09\u4e2a\u6708\u4e4b\u5185&lt;\/option&gt;\r\n            &lt;option value=\"4\"&gt;\u5927\u4e8e\u4e09\u4e2a\u6708&lt;\/option&gt;\r\n        &lt;\/select&gt;\r\n        &lt;input type=\"submit\" value=\"\u7b5b\u9009\u67e5\u8be2\" class=\"submit\" \/&gt;\r\n    &lt;\/form&gt;\r\n&lt;\/body&gt;\r\n\r\n&lt;\/html&gt;<\/code><\/pre>\n<p style=\"box-sizing: border-box; margin: 0px 0px 16px; outline: 0px; padding: 0px; color: #4f4f4f; line-height: 26px; text-align: justify; word-break: break-all; font-family: -apple-system, 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif, SimHei, SimSun; background-color: #ffffff;\">\u63a7\u5236\u5668<span style=\"box-sizing: border-box; outline: 0px; word-break: break-all; color: #ff0000;\"><span style=\"box-sizing: border-box; outline: 0px; font-weight: bold; word-break: break-all;\">IndexController.class.php<\/span><\/span><\/p>\n<pre class=\"language-php\"><code>public function search() {\r\n        if (isset($_GET['add_time']) &amp;&amp; $_GET['add_time'] != 999) {\/\/\u5224\u65ad\u662f\u5426\u6709\u63a5\u6536\u7b5b\u9009\u67e5\u8be2\r\n            $add_time = I(\"get.add_time\");\r\n            if ($add_time == 0) {\r\n                $today = date('Y-m-d 00:00:00');\r\n                $condition['add_time'] = array('egt', $today);\/\/\u4eca\u5929\u7684\u6570\u636e\r\n                $add_time = 0;\r\n                $this-&gt;assign('add_time', $add_time); \/\/ \u6a21\u677f\u8d4b\u503c\uff0c\u4ee5\u4fbf\u524d\u7aef\u9009\u62e9\u7b5b\u9009\u7684\u9009\u62e9\u503c\u5728\u9875\u9762\u7b5b\u9009\u52a0\u8f7d\u540e\u4f9d\u65e7\u5b58\u5728\r\n            }\r\n            if ($add_time == 1) {\r\n                $weekend = date(\"Y-m-d H:i:s\", strtotime('-7 days'));\/\/\u4e00\u5468\u4e4b\u5185\u7684\u6570\u636e\r\n                $condition['add_time'] = array('egt', $weekend);\r\n                $add_time = 1;\r\n                $this-&gt;assign('add_time', $add_time);\r\n            }\r\n            if ($add_time == 2) {\r\n                $monthday = date(\"Y-m-d H:i:s\", strtotime('-1 months'));\/\/\u4e00\u4e2a\u6708\u4e4b\u5185\u7684\u6570\u636e\r\n                $condition['add_time'] = array('egt', $monthday);\r\n                $add_time = 2;\r\n                $this-&gt;assign('add_time', $add_time); \/\/ \u6a21\u677f\u8d4b\u503c\uff0c\u4ee5\u4fbf\u524d\u7aef\u9009\u62e9\u7b5b\u9009\u7684\u9009\u62e9\u503c\u5728\u9875\u9762\u7b5b\u9009\u52a0\u8f7d\u540e\u4f9d\u65e7\u5b58\u5728\r\n            }\r\n            if ($add_time == 3) {\r\n                $monthdays = date(\"Y-m-d H:i:s\", strtotime('-3 months'));\/\/\u4e09\u4e2a\u6708\u4e4b\u5185\u7684\u6570\u636e\r\n                $condition['add_time'] = array('egt', $monthdays);\r\n                $add_time = 3;\r\n                $this-&gt;assign('add_time', $add_time); \/\/ \u6a21\u677f\u8d4b\u503c\uff0c\u4ee5\u4fbf\u524d\u7aef\u9009\u62e9\u7b5b\u9009\u7684\u9009\u62e9\u503c\u5728\u9875\u9762\u7b5b\u9009\u52a0\u8f7d\u540e\u4f9d\u65e7\u5b58\u5728\r\n            }\r\n            if ($add_time == 4) {\r\n                $moreMonthdays = date(\"Y-m-d H:i:s\", strtotime('-3 months'));\/\/\u4e09\u4e2a\u6708\u4ee5\u4e0a\u7684\u6570\u636e\r\n                $condition['add_time'] = array('lt', $moreMonthdays);\r\n                $add_time = 4;\r\n                $this-&gt;assign('add_time', $add_time); \/\/ \u6a21\u677f\u8d4b\u503c\uff0c\u4ee5\u4fbf\u524d\u7aef\u9009\u62e9\u7b5b\u9009\u7684\u9009\u62e9\u503c\u5728\u9875\u9762\u7b5b\u9009\u52a0\u8f7d\u540e\u4f9d\u65e7\u5b58\u5728\r\n            }\r\n        }\r\n        $Log = M(\"log\");\r\n        $logInfo = $Log-&gt;where($condition)-&gt;select();\r\n        $this-&gt;assign(\"logInfo\", $logInfo);\r\n        $this-&gt;display(\"index\");\r\n    }<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6570\u636e\u8868\u4e2d\u6587\u7ae0\u6dfb\u52a0\u7684\u65f6\u95f4\u5b57\u6bb5\u5b58\u50a8\u6570\u636e\u7c7b\u578b\u4e3a\uff1adatetime \u6a21\u677f\u9875\u9762index.html \u521b\u5efa\u4e00\u4e2a\u8868\u5355\uff0c\u4ee5\u4fbf\u9009 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[29],"class_list":["post-156","post","type-post","status-publish","format-standard","hentry","category-thinkphp","tag-thinkphp"],"_links":{"self":[{"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/posts\/156","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=156"}],"version-history":[{"count":0,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/posts\/156\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.djlog.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=156"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}