Advertisement
murp

ColdFusion ArrayToQuery

Jul 25th, 2015
652
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. * arrayToQuery
  3. * Allows us to convert an array into a single column query.
  4. * @author   Ryan Mueller @CreativeNotice
  5. * @created  10/27/2011
  6. * @param    {Array}     arr Array to be converted       {required}
  7. * @param    {String}    colname Name for query column   {required}  default=col1
  8. */
  9. public Query function arrayToQuery(required array arr,required string colname='col1'){
  10.     var qry = queryNew(arguments.colname);
  11.     for(i=1;i <= ArrayLen(arguments.arr);i=(i+1)){
  12.        queryAddRow(qry);
  13.        querySetCell(qry,arguments.colname,arr[i]);
  14.    }
  15.    return qry;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement