I'm working on an application with a friend of mine and we're taking full advantage of all the great new functions and features in Open BlueDragon. One of the new functions I wasn't sure I'd use all that much is QueryRun(), which lets you run a query in a CFSCRIPT block like this:
<cfscript>
QueryRun(datasource, sqlStatement, queryParams);
</cfscript>
Let's look at a concrete example. Assume a table called "user" with fields of id, email, first_name, and last_name, and a datasource named "myDSN". To pull all the users, you'd do this:
<cfscript>
getUsersSQL = "SELECT id, email, first_name, last_name FROM user";
users = QueryRun("myDSN", getUsersSQL);
</cfscript>
Now if you want to pull a specific user--let's say by email--you can parameterize your queries by using an array of structs that represent the CFQUERYPARAM tags, where the key in each struct is the attribute name from CFQUERYPARAM, and the …
<cfscript>
QueryRun(datasource, sqlStatement, queryParams);
</cfscript>
Let's look at a concrete example. Assume a table called "user" with fields of id, email, first_name, and last_name, and a datasource named "myDSN". To pull all the users, you'd do this:
<cfscript>
getUsersSQL = "SELECT id, email, first_name, last_name FROM user";
users = QueryRun("myDSN", getUsersSQL);
</cfscript>
Now if you want to pull a specific user--let's say by email--you can parameterize your queries by using an array of structs that represent the CFQUERYPARAM tags, where the key in each struct is the attribute name from CFQUERYPARAM, and the …