Created
May 8, 2013 00:05
-
-
Save joshknutson/5537205 to your computer and use it in GitHub Desktop.
ability to copy in a query that has the params that coldfusion gives you when it gives you an exception, this will give you the real query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfsilent> | |
</cfsilent> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | |
<title>cfQueryDumpFixer</title> | |
<meta name="viewport" content="width=device-width" /> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> | |
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/css/bootstrap-combined.min.css" rel="stylesheet"> | |
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/js/bootstrap.min.js"></script> | |
</head> | |
<body> | |
<cfif !structKeyExists(form,"sql")> | |
<form class="form-horizontal" method="post"> | |
<fieldset> | |
<div class="control-group"> | |
<label class="control-label" for="sql">Sql</label> | |
<span class="controls"> | |
<textarea name="sql" id="sql" placeholder="insert your sql here"></textarea> | |
</span> | |
</div> | |
<div class="control-group"> | |
<label class="control-label" for="where">where</label> | |
<span class="controls"> | |
<textarea name="where" id="where" placeholder="insert your where here"></textarea> | |
<span class="help-block">its the datas with your params</span> | |
</span> | |
</div> | |
</fieldset> | |
<button type="submit" class="btn">Submit</button> | |
</form> | |
<cfelse> | |
<h2>Result</h2> | |
<cfset sql = form.sql /> | |
<cfset params = rematchnocase("value='+.+?'+",where) /> | |
<cfset result = sql /> | |
<cfloop from="1" to="#arraylen(params)#" index="i"> | |
<cfset item=params[i] /> | |
<cfset item = listlast(item,"=") /> | |
<cfset item = mid(item,2,len(item)-2) /> | |
<cfset result = replaceNoCase(result,"(param #i#)",item) /> | |
</cfloop> | |
<cfset result = replace(result,"(","#chr(10)#(","all") /> | |
<cfoutput> | |
<pre> | |
#result# | |
</pre> | |
<cfdump label="params passed in" var="#params#" /> | |
</cfoutput> | |
</cfif> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment