{"id":596,"date":"2012-10-25T01:57:52","date_gmt":"2012-10-24T20:57:52","guid":{"rendered":"http:\/\/www.esearing.com\/v2010\/?p=596"},"modified":"2012-10-25T01:57:52","modified_gmt":"2012-10-24T20:57:52","slug":"cfqueryparam-with-lists","status":"publish","type":"post","link":"https:\/\/www.esearing.com\/v2010\/2012\/10\/cfqueryparam-with-lists\/","title":{"rendered":"CFQueryParam with Lists"},"content":{"rendered":"<p>If you have a form that gathers an element where the user can enter several items separated by commas, coldfusion gives you a couple of ways to deal with the sql statement. In older versions you might loop  through the formelement.values. But in CF8 forward you can use CFQueryParam with the LIST=&#8221;yes&#8221; attribute.<\/p>\n<p>Example<br \/>\nFormElement Favorite_fruits [apples,oranges,pears]<\/p>\n<p><code>SQL -- Who else likes your favorite foods?<br \/>\nselect people from favorite_foods_table<br \/>\nwhere favorite_fruits in (&lt;cfqueryparam value=\"#favorite_fruits#\" list=\"yes\" \/&gt;)<br \/>\n<\/code><\/p>\n<p>You may also need to deal with spaces between fruits by using character replacement. In this case I get rid of all spaces.<\/p>\n<p><code>&lt;cfqueryparam value=\"#rereplace(favorite_fruits, ' ', '','ALL')#\" list=\"yes\" \/&gt;<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you have a form that gathers an element where the user can enter several items separated by commas, coldfusion gives you a couple of ways to deal with the sql statement. In older versions you might loop through the &hellip; <a href=\"https:\/\/www.esearing.com\/v2010\/2012\/10\/cfqueryparam-with-lists\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,16,24,14],"tags":[],"class_list":["post-596","post","type-post","status-publish","format-standard","hentry","category-code","category-coldfusion","category-snippets-quick-code-tips-for-single-elements-attributes-or-details","category-sql"],"_links":{"self":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/posts\/596","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/comments?post=596"}],"version-history":[{"count":2,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/posts\/596\/revisions"}],"predecessor-version":[{"id":598,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/posts\/596\/revisions\/598"}],"wp:attachment":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/media?parent=596"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/categories?post=596"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/tags?post=596"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}