Last active
June 3, 2018 16:24
-
-
Save mpadmore/e3abb97329a4e3ee889a21b2cc3f98ab to your computer and use it in GitHub Desktop.
Example of queryExecute
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
<cfscript> | |
people = queryNew( | |
"id, firstName, lastName, email, country, ip_address", | |
"integer, varchar, varchar, varchar, varchar, varchar", | |
[{ | |
"id": 1, | |
"firstName": "Christopher", | |
"lastName": "Burton", | |
"email": "[email protected]", | |
"country": "Poland", | |
"ip_address": "81.248.29.126" | |
}, { | |
"id": 2, | |
"firstName": "Scott", | |
"lastName": "Vasquez", | |
"email": "[email protected]", | |
"country": "Iceland", | |
"ip_address": "225.10.179.213" | |
}, { | |
"id": 3, | |
"firstName": "Earl", | |
"lastName": "Berry", | |
"email": "[email protected]", | |
"country": "Sri Lanka", | |
"ip_address": "110.242.80.67" | |
}, { | |
"id": 4, | |
"firstName": "Brian", | |
"lastName": "Turner", | |
"email": "[email protected]", | |
"country": "China", | |
"ip_address": "140.86.69.145" | |
}, { | |
"id": 5, | |
"firstName": "Jimmy", | |
"lastName": "Mccoy", | |
"email": "[email protected]", | |
"country": "Vietnam", | |
"ip_address": "215.144.2.198" | |
}, { | |
"id": 6, | |
"firstName": "Bruce", | |
"lastName": "Williams", | |
"email": "[email protected]", | |
"country": "Russia", | |
"ip_address": "130.107.175.112" | |
}, { | |
"id": 7, | |
"firstName": "Peter", | |
"lastName": "Cox", | |
"email": "[email protected]", | |
"country": "United States", | |
"ip_address": "155.3.57.239" | |
}, { | |
"id": 8, | |
"firstName": "Edward", | |
"lastName": "Cook", | |
"email": "[email protected]", | |
"country": "France", | |
"ip_address": "253.187.203.194" | |
}, { | |
"id": 9, | |
"firstName": "Christopher", | |
"lastName": "Burns", | |
"email": "[email protected]", | |
"country": "Indonesia", | |
"ip_address": "198.207.147.137" | |
}, { | |
"id": 10, | |
"firstName": "Phillip", | |
"lastName": "Duncan", | |
"email": "[email protected]", | |
"country": "China", | |
"ip_address": "153.44.71.214" | |
}] | |
); | |
writeDump(people); | |
// CF11+ or Lucee | |
filterA = "China"; | |
filterB = "P%"; | |
peopleQ2 = queryExecute( | |
"SELECT * FROM people WHERE country = :country", | |
{country: filterA}, | |
{dbType:"query"} | |
); | |
writeDump(peopleQ2); | |
peopleQ3 = queryExecute( | |
"SELECT * FROM people WHERE firstname LIKE :firstname", | |
{firstname: filterB}, | |
{dbType:"query"} | |
); | |
writeDump(peopleQ3); | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment