Advertisement
Guest User

Untitled

a guest
May 19th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     <cfset where=ArrayNew(1)>
  2.     <cfset whereStruct=StructNew()>
  3.     <cfset a=StructInsert(whereStruct, "field", "state") >
  4.     <cfset a=StructInsert(whereStruct, "type",  "string") >
  5.     <cfset a=StructInsert(whereStruct, "value", "#url.stateSel#") >
  6.  
  7.     <cfset a=ArrayAppend(where, whereStruct)>
  8.     <cfdump var="#whereStruct#">
  9.     <cfdump var="#where#">
  10.     <cfdump var="#where[1]['type']#">
  11.  
  12.     <cfquery name="CategoryCount" datasource="PJ">
  13.         select Category, COUNT(category) as count
  14.             FROM UserProfile
  15.  
  16.                         <cfset dontdothisagain = false />
  17.             <cfloop array="#where#" index="i">
  18.                 <cfif dontdothisagain eq false> WHERE <cfelse> AND </cfif> #i['field']# = <cfqueryparam CFSQLTYPE="#i['type']#" value="#i['value']#" />
  19.                                 <cfset dontdothisagain = true />
  20.             </cfloop>
  21.  
  22.             group by Category
  23.     </cfquery>
  24.  
  25.  
  26.  
  27.  
  28. struct
  29. field   state
  30. type    string
  31. value   IA
  32. array
  33. 1  
  34. struct
  35. field   state
  36. type    string
  37. value   IA
  38. string
  39.  
  40. String: stateSel=IA&city=des+moines
  41.  
  42. ------------------------------------
  43. Complex object types cannot be converted to simple values. The expression has requested a variable or an intermediate expression result as a simple value, however, the result cannot be converted to a simple value. Simple values are strings, numbers, boolean values, and date/time values. Queries, arrays, and COM objects are examples of complex values.
  44.  
  45. The most likely cause of the error is that you are trying to use a complex value as a simple one. For example, you might be trying to use a query variable in a cfif tag.
  46. The error occurred on line 67.
  47.  
  48.  
  49. (line 67 is the middle of the cfloop that builds the where inside the query)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement