如何在coldfusion中检查来自valuelist的值

时间:2015-07-23 19:43:50

标签: coldfusion coldfusion-9 coldfusion-10 coldfusion-11

我的记录显示如下:

name, id, gender, itemvalue
steve, 123, M,    (3,4,5)
bond, 456,  M,    (5,4)
James, 345,   F,  (4,7)

在另一个表中,我引用了这样的itemvalues:

3='test' 
4='coder'
5='admin'

现在在记录值中,如何检查itemvalues中的单个值? 例如,在ColdFusion中检查Steve的itemvalue是否为5?

<cfif steve.itemvalue EQ 5>
      do this
<cfelse>
      if not 5 do this
</cfif>  

1 个答案:

答案 0 :(得分:0)

您可以像这样使用ListFind()

<cfloop query="getEmployee">
  <cfif findNoCase("steve", getEmployee.name) AND listFind(getEmployee.itemValue, "5">
    do this
  <cfelse>  
    if not 5 do this
  </cfif>
</cfloop>