cfjedimaster

Untitled

Mar 27th, 2012
4,133
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. component {
  2.  
  3.     remote array function getSuggestions(required string search) returnFormat=json {
  4.         var q = new com.adobe.coldfusion.query();
  5.         q.setDatasource("cfartgallery");
  6.         q.setSQL("select firstname,lastname from artists where lower(lastname) like :search or lower(firstname) like :search");
  7.         q.addParam(name="search",value="%#lcase(arguments.search)#%",cfsqltype="cf_sql_varchar");
  8.         var res = q.execute().getResult();
  9.         var result = [];
  10.         for(var i=1; i<=res.recordCount; i++) {
  11.             arrayAppend(result, "#res.lastname[i]#, #res.firstname[i]#");
  12.         }
  13.         return result;
  14.     }
  15. }
RAW Paste Data