Wrapping list elements with single quotes in cfml

Author: Steven Neiland
Published:

Warning: This blog entry was written two or more years ago. Therefore, it may contain broken links, out-dated or misleading content, or information that is just plain wrong. Please read on with caution.

A few weeks ago I needed to modify a list to wrap each list element with single quotes. Normally you would do this when outputting the data in a view but in this case that was not an option.

I was about to write a function to to this when I decided to take a chance that someone had already written this for me. A quick google later and I discovered that ColdFusion has a builtin function for exactly this purpose named "listQualify()".

Example

unqualifiedList = "dog,cat,bird,pig";
qualifiedList = listQualify(unqualifiedList, "'");
unqualifiedList: dog,cat,bird,pig
qualifiedList: 'dog','cat','bird','pig'

It seems even after all these years I am still learning new things about cfml.

Reader Comments

sathya's Gravatar
sathya
Friday, May 15, 2015 at 7:45:57 AM Coordinated Universal Time

how to insert multiple rows into single sql server

Dani's Gravatar
Dani
Wednesday, July 13, 2022 at 2:40:06 PM Coordinated Universal Time

7 years later and still relevant. Thank you Steve for writing this short and sweet post :)

  • Please keep comments on-topic.
  • Please do not post unrelated questions or large chunks of code.
  • Please do not engage in flaming/abusive behaviour.
  • Comments that contain advertisments or appear to be created for the purpose of link building, will not be published.

Archives Blog Listing