
{"id":1822,"date":"2022-06-22T10:58:30","date_gmt":"2022-06-22T02:58:30","guid":{"rendered":"http:\/\/dba.qishuo.xin\/?p=1822"},"modified":"2022-06-22T11:43:53","modified_gmt":"2022-06-22T03:43:53","slug":"mybatis%e6%97%a5%e5%bf%97%e8%bd%acsql","status":"publish","type":"post","link":"http:\/\/dba.qishuo.xin\/?p=1822","title":{"rendered":"MyBatis\u65e5\u5fd7\u8f6cSQL"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_76 ez-toc-wrap-right counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<label for=\"ez-toc-cssicon-toggle-item-6a351f7306f50\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a351f7306f50\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"http:\/\/dba.qishuo.xin\/?p=1822\/#%E4%B8%80%E3%80%81%E8%BE%93%E5%85%A5Mybatis_SQL%E6%97%A5%E5%BF%97%EF%BC%9A\" >\u4e00\u3001\u8f93\u5165Mybatis SQL\u65e5\u5fd7\uff1a<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"http:\/\/dba.qishuo.xin\/?p=1822\/#%E4%BA%8C%E3%80%81%E8%A7%A3%E6%9E%90%E4%B8%BA%E5%8F%AF%E6%89%A7%E8%A1%8CSQL%EF%BC%9A\" >\u4e8c\u3001\u89e3\u6790\u4e3a\u53ef\u6267\u884cSQL\uff1a<\/a><\/li><\/ul><\/nav><\/div>\n<p><html><br \/>\n<head><br \/>\n    <meta charset=\"utf-8\"><br \/>\n    <title><\/title><br \/>\n    <script type=\"text\/javascript\">\n        function f(obj) {\n            var textVa = obj.value;\n            \/\/ \u83b7\u53d6\u5e26\u95ee\u53f7\u7684SQL\u8bed\u53e5\n            var statementStartIndex = textVa.indexOf('Preparing: ');\n            var statementEndIndex = textVa.length - 1;\n            for (var i = statementStartIndex; i < textVa.length; i++) {\n                if (textVa[i] == \"\\n\") {\n                    statementEndIndex = i;\n                    break;\n                }\n            }\n            var statementStr = textVa.substring(statementStartIndex + \"Preparing: \".length, statementEndIndex);\n            console.log(statementStr);\n            \/\/\u83b7\u53d6\u53c2\u6570\n            var parametersStartIndex = textVa.indexOf('Parameters: ');\n            var parametersEndIndex = textVa.length - 1;\n            for (var i = parametersStartIndex; i < textVa.length; i++) {\n                if (textVa[i] == \"\\n\") {\n                    parametersEndIndex = i;\n                    break;\n                } else {\n                    console.log(textVa[i]);\n                }\n            }\n            var parametersStr = textVa.substring(parametersStartIndex + \"Parameters: \".length, parametersEndIndex);\n            parametersStr = parametersStr.split(\",\");\n            console.log(parametersStr);\n            for (var i = 0; i < parametersStr.length; i++) {\n                \/\/ \u5982\u679c\u6570\u636e\u4e2d\u5e26\u62ec\u53f7\u5c06\u4f7f\u7528\u5176\u4ed6\u903b\u8f91\n                tempStr = parametersStr[i].substring(0, parametersStr[i].indexOf(\"(\"));\n                \/\/ \u83b7\u53d6\u62ec\u53f7\u4e2d\u5185\u5bb9\n                typeStr = parametersStr[i].substring(parametersStr[i].indexOf(\"(\") + 1, parametersStr[i].indexOf(\")\"));\n                \/\/ \u5982\u679c\u4e3a\u5b57\u7b26\u7c7b\u578b\n                if (typeStr == \"String\" || typeStr == \"Timestamp\") {\n                    statementStr = statementStr.replace(\"?\", \"'\" + tempStr.trim() + \"'\");\n                } else {\n                    \/\/ \u6570\u503c\u7c7b\u578b\n                    statementStr = statementStr.replace(\"?\", tempStr.trim());\n                }\n            }\n            console.log(statementStr);\n            document.getElementById(\"d1\").innerHTML = statementStr;\n            return textVa;\n        }\n\n        function copySQL() {\n            var SQL = document.getElementById(\"d1\");\n            SQL.select(); \/\/ \u9009\u62e9\u5bf9\u8c61\n            document.execCommand(\"Copy\"); \/\/ \u6267\u884c\u6d4f\u89c8\u5668\u590d\u5236\u547d\u4ee4\n            var msg = document.getElementById(\"msg\");\n            msg.innerHTML = \"\u5df2\u590d\u5236\u5230\u526a\u5207\u677f\";\n            setTimeout(function () {\n                msg.innerHTML = \"\";\n            }, 3000);\n\n        }\n\n        function clearLog(obj) {\n            obj.select();\n            obj.value = \"\";\n        }\n\n    <\/script><br \/>\n<\/head><br \/>\n<body><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E4%B8%80%E3%80%81%E8%BE%93%E5%85%A5Mybatis_SQL%E6%97%A5%E5%BF%97%EF%BC%9A\"><\/span><font color=\"#00bfff\">\u4e00\u3001\u8f93\u5165Mybatis SQL\u65e5\u5fd7\uff1a<\/font><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><textarea id=\"sqlLog\" rows=\"20\" cols=\"140\" style=\"font-size:20px\"><\/textarea><\/p>\n<div style=\"border:0px deepskyblue solid;width:800px;height:50px;text-align:right\">\n    <button style=\"color:mediumblue;width:100px;height:40px\" type=\"button\"\n            onclick=\"clearLog(document.getElementById('sqlLog'))\">\u6e05\u7a7a<br \/>\n    <\/button>\u3000\u3000\u3000\u3000<button style=\"color:mediumblue;width:100px;height:40px\" type=\"submit\"\n            onclick=\"f(document.getElementById('sqlLog'))\">\u89e3\u6790SQL<br \/>\n    <\/button>\n<\/div>\n<h3><span class=\"ez-toc-section\" id=\"%E4%BA%8C%E3%80%81%E8%A7%A3%E6%9E%90%E4%B8%BA%E5%8F%AF%E6%89%A7%E8%A1%8CSQL%EF%BC%9A\"><\/span><font color=\"#32cd32\">\u4e8c\u3001\u89e3\u6790\u4e3a\u53ef\u6267\u884cSQL\uff1a<\/font><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><textarea id=\"d1\" rows=\"20\" cols=\"140\" style=\"font-size:20px\"><\/textarea><\/p>\n<div style=\"border:0px deepskyblue solid;width:800px;height:50px;text-align:right\">\n    <button style=\"color:mediumblue;width:100px;height:40px\" type=\"button\" onclick=\"copySQL()\">\u590d\u5236SQL<\/button>\n<\/div>\n<div id=\"msg\"\n     style=\"color:cornflowerblue;border:0px black solid;width:800px;height:20px;text-align:right;font-style: initial;font-size: large\">\n<\/div>\n<p><\/body><br \/>\n<\/html><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u8f93\u5165Mybatis SQL\u65e5\u5fd7\uff1a \u6e05\u7a7a \u3000\u3000\u3000&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1822","post","type-post","status-publish","format-standard","hentry","category-wordpress"],"_links":{"self":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts\/1822","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1822"}],"version-history":[{"count":13,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts\/1822\/revisions"}],"predecessor-version":[{"id":1837,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts\/1822\/revisions\/1837"}],"wp:attachment":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1822"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1822"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1822"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}