I used to think that ColdFusion CFQueryParam's List and Null attributes required a "Yes" or "No" string. I always thought this was unusual, since so much of ColdFusion Yes/No attributes simply require a boolean value (ex. True, 1, 0, False). And, more than that, I could have sworn that I even tested this and was disappointed to see that true/false values actually threw ColdFusion exceptions!
But, apparently I read that somewhere and just accepted it like some ColdFusion Sheep in the herd. Thankfully, Elliott Sprehn has shown me the error of my ways. He told me that, like most of ColdFusion, the CFQueryParam Null and List attributes can, in fact, take standard boolean values:
Launch code in new window » Download code as text file »
When I run that, I get a ColdFusion query returned, not the formerly expected ColdFusion error. This is sweet-ass-sweet news! I always hated using the YesNoFormat() method as it adds so much noise to the already verbose ColdFusion CFQueryParam tag. This is gonna be so much nicer to use!
Download Code Snippet ZIP File
Comments (3) | Post Comment | Ask Ben | Permalink | Print Page
You're Welcome!
Posted by Elliott Sprehn on Jul 17, 2007 at 5:18 PM
I love learning these little things that end up having a huge impact on the way I code.
Posted by Ben Nadel on Jul 17, 2007 at 5:24 PM
Nice one Ben, for more reading: http://www.chapter31.com/2007/02/04/cfqueryparam-and-conditional-handling-of-nulls/
Posted by Michael Sharman on Jul 17, 2007 at 6:47 PM