{"id":263,"date":"2021-05-08T06:41:23","date_gmt":"2021-05-07T22:41:23","guid":{"rendered":"http:\/\/blog.yuekegu.com\/?p=263"},"modified":"2021-05-08T06:41:23","modified_gmt":"2021-05-07T22:41:23","slug":"%e5%85%b3%e4%ba%8e%e4%b8%8a%e4%b8%80%e9%a1%b5%e4%b8%8e%e4%b8%8b%e4%b8%80%e9%a1%b5%e5%ae%9e%e7%8e%b0%e7%bb%86%e8%8a%82","status":"publish","type":"post","link":"https:\/\/book.yuekegu.com\/index.php\/2021\/05\/08\/%e5%85%b3%e4%ba%8e%e4%b8%8a%e4%b8%80%e9%a1%b5%e4%b8%8e%e4%b8%8b%e4%b8%80%e9%a1%b5%e5%ae%9e%e7%8e%b0%e7%bb%86%e8%8a%82\/","title":{"rendered":"\u5173\u4e8e\u4e0a\u4e00\u9875\u4e0e\u4e0b\u4e00\u9875\u5b9e\u73b0\u7ec6\u8282"},"content":{"rendered":"\n<p>\u6211\u60f3\u8981\u628a\u9898\u5e93\u8bbe\u8ba1\u4e00\u4e0b\u7ffb\u9875\u529f\u80fd\uff0cMysql\u8bed\u53e5\u4e5f\u5f88\u7b80\u5355\uff0c\u5728\u672c\u5730\u6d4b\u8bd5\u4e00\u70b9\u95ee\u9898\u90fd\u6ca1\u6709\uff0c\u4f46\u662f\u4e00\u653e\u5230\u670d\u52a1\u5668\u4e0a\u4fbf\u63d0\u793a\u5185\u5b58\u8d44\u6e90\u8017\u7aed\uff0c\u6700\u540e\u5728\u67e5\u770b\u4e86\u4e00\u4e9b\u8d44\u6599\u540e\uff0c\u5728\u540e\u9762\u52a0\u4e86\u4e00\u4e2alimit 1\uff0c\u5982\u6b64\u4fbf\u8dd1\u5f97\u98de\u5feb\uff1a<\/p>\n\n\n\n<p>\u5b9e\u73b0\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    public static function PrevQuestion($id,$uid=null,$testpaper=null)\n    {\n        $query = Question::find()->where(['&lt;','id',$id]);\n\n        if($uid)\n        {\n            $query->andWhere(['author'=>$uid]);\n        }\n\n        if($paper)\n        {\n            $query->LeftJoin('sq_testpaperinfo t','t.paper_id='.$paper_id);\n        }\n\n        $query->orderBy('id DESC');\n\n        $query->limit(1);\n\n        return $query->one();\n    }\n\n    public static function NextQuestion($id,$uid=null,$testpaper=null)\n    {\n        $query = Question::find()->where(['>','id',$id]);\n\n        if($uid)\n        {\n            $query->andWhere(['author'=>$uid]);\n        }\n\n        if($paper)\n        {\n            $query->LeftJoin('sq_testpaperinfo t','t.paper_id='.$paper_id);\n        }\n\n        $query->orderBy('id DESC');\n        $query->limit(1);\n\n        return $query->one();\n    }<\/code><\/pre>\n\n\n\n<p>\u4e0b\u9762\u662f\u53c2\u8003\u5185\u5bb9\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n* \u83b7\u53d6\u5f53\u524d\u8bb0\u5f55\u7684\u4e0a\u4e00\u6761\u8bb0\u5f55\n* @param seq\n* @return\n*\/\n@Select(\"select title, random_code from tb_blog where seq &lt; ${seq} order by seq desc limit 1 \")\npublic Map&lt;String,Object> getPreviousBlog(@Param(\"seq\") long seq);\n\n\/**\n* \u83b7\u53d6\u5f53\u524d\u8bb0\u5f55\u7684\u4e0b\u4e00\u6761\u8bb0\u5f55\n* @param seq\n* @return\n*\/\n@Select(\"select title, random_code from tb_blog where seq > ${seq} order by seq asc limit 1 \")\npublic Map&lt;String,Object> getPostBlog(@Param(\"seq\") long seq);<\/code><\/pre>\n\n\n\n<p>seq&nbsp;\u662f\u81ea\u589e\u5e8f\u5217\uff0crandom_code\u662fid\uff0ctitle\u662f\u535a\u5ba2\u6807\u9898\u3002<\/p>\n\n\n\n<p>seq\u4e0d\u662f\u4e3b\u952e\uff0c\u8981\u4f7fseq\u81ea\u589e\uff0c\u5148\u6dfb\u52a0seq\u5b57\u6bb5\u6216\u5efa\u8868\u65f6\u521b\u5efa\uff0c\u518d\u5c06seq\u6dfb\u52a0unique\u7d22\u5f15\uff0c\u518d\u4f7fseq auto_increment\uff0c\u56e0\u4e3a\u81ea\u589e\u957f\u5217\u5fc5\u987b\u5148\u662funique key\u6216primary key\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u60f3\u8981\u628a\u9898\u5e93\u8bbe\u8ba1\u4e00\u4e0b\u7ffb\u9875\u529f\u80fd\uff0cMysql\u8bed\u53e5\u4e5f\u5f88\u7b80\u5355\uff0c\u5728\u672c\u5730\u6d4b\u8bd5\u4e00\u70b9\u95ee\u9898\u90fd\u6ca1\u6709\uff0c\u4f46\u662f\u4e00\u653e\u5230\u670d\u52a1\u5668\u4e0a\u4fbf\u63d0\u793a\u5185\u5b58\u8d44\u6e90\u8017\u7aed\uff0c\u6700\u540e\u5728\u67e5\u770b\u4e86\u4e00\u4e9b\u8d44\u6599\u540e\uff0c\u5728\u540e\u9762\u52a0\u4e86\u4e00\u4e2alimit 1\uff0c\u5982\u6b64\u4fbf\u8dd1\u5f97\u98de\u5feb\uff1a \u5b9e\u73b0\u4ee3\u7801\uff1a \u4e0b\u9762\u662f\u53c2\u8003\u5185\u5bb9\uff1a seq&nbsp;\u662f\u81ea\u589e\u5e8f\u5217\uff0crandom_code\u662fid\uff0ctitle\u662f\u535a\u5ba2\u6807\u9898\u3002 seq\u4e0d\u662f\u4e3b\u952e\uff0c\u8981\u4f7fseq\u81ea\u589e\uff0c\u5148\u6dfb\u52a0seq\u5b57\u6bb5\u6216\u5efa\u8868\u65f6\u521b\u5efa\uff0c\u518d\u5c06seq\u6dfb\u52a0unique\u7d22\u5f15\uff0c\u518d\u4f7fseq auto_increment\uff0c\u56e0\u4e3a\u81ea\u589e\u957f\u5217\u5fc5\u987b\u5148\u662funique key\u6216primary key\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,27],"tags":[],"class_list":["post-263","post","type-post","status-publish","format-standard","hentry","category-yii2","category-27"],"_links":{"self":[{"href":"https:\/\/book.yuekegu.com\/index.php\/wp-json\/wp\/v2\/posts\/263","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/book.yuekegu.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/book.yuekegu.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/book.yuekegu.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/book.yuekegu.com\/index.php\/wp-json\/wp\/v2\/comments?post=263"}],"version-history":[{"count":0,"href":"https:\/\/book.yuekegu.com\/index.php\/wp-json\/wp\/v2\/posts\/263\/revisions"}],"wp:attachment":[{"href":"https:\/\/book.yuekegu.com\/index.php\/wp-json\/wp\/v2\/media?parent=263"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/book.yuekegu.com\/index.php\/wp-json\/wp\/v2\/categories?post=263"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/book.yuekegu.com\/index.php\/wp-json\/wp\/v2\/tags?post=263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}