Posted in Javascript onApril 03, 2015
sql转换为stringBuffer的小工具,dao层拼接sql很麻烦,用这个小工具可以快速拼接,把写好的sql在sql工具中格式化好,然后复制进去就可以了
演示地址:http://runjs.cn/detail/fj14tpyu 有点丑,建议全屏查看,不过你下载下来可以自己修改
代码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>change SQL</TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> <script> var ie = !-[1,]; function changeSQL(){ var srcSQL = document.getElementById("srcSQL"); var srcInner = srcSQL.value; var sqlBuf = "sqlBuf" var BufObj = "StringBuffer sqlBuf = new StringBuffer();" var newSrc = ""; if(ie){ var newSrc = srcInner.split("\r\n"); }else{ var patt = new RegExp(/.+/g); var newSrc = srcInner.match(patt); } var len = newSrc.length; for(var i=0;i<len;i++){ var temp=newSrc[i]; if(i < len-1){ sqlBuf += ".append(\" " + temp + " \")" + "\r\n"; } if(i == len-1){ sqlBuf += ".append(\" " + temp + " \");"; } } var showSQL = document.getElementById("showSQL"); showSQL.innerText = BufObj + "\n" + sqlBuf; } </script> </HEAD> <BODY> <table border="1" width="100%" > <tr align="center"> <td width="45%"><textarea id="srcSQL" rows="40" cols="85" ></textarea></td> <td> <button onclick="changeSQL()" style="cursor:hand;"><font color="blue" size="5"><b>转换</b></button><p> </td> <td width="45%"><textarea id="showSQL" rows="40" cols="85" ></textarea></td> </tr> </table> </BODY> </HTML>
以上所述就是本文的全部内容了,希望大家能够喜欢。
javascript制作sql转换为stringBuffer的小工具
- Author -
hebedich声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@