CF8
我正用这条线来获取查询列的 MIN 值。 我刚刚注意到一个记录栏中的无效值造成了错误。 是否有简单的方法可以让ArrayMin 跳过列以绕行, 并装入包含全部非null 值的数组?
<cfset temp_data_min = #round(ArrayMin(query_x["some_field"]))#>
谢谢!
CF8
我正用这条线来获取查询列的 MIN 值。 我刚刚注意到一个记录栏中的无效值造成了错误。 是否有简单的方法可以让ArrayMin 跳过列以绕行, 并装入包含全部非null 值的数组?
<cfset temp_data_min = #round(ArrayMin(query_x["some_field"]))#>
谢谢!
您可以绕过您的数组, 创建一个新的数组, 新数组不包含任何空值。 然后对新数组应用 ArrayMin 函数 。
<cfset newArray = []>
<cfloop index="x" array="#query_x["some_field"]#">
<cfif x NEQ null >
<cfset arrayAppend(newArray, x)>
</cfif>
</cfloop>
<cfset temp_data_min = round(ArrayMin(newArray))>
未测试
建立 Al 使用询问查询时所说的话, 只是在查询中添加 Min () 调用 。
<cfquery name="query_x_fixed" dbtype="query">
SELECT Min(some_field) as some_field
FROM query_x
WHERE some_field IS NOT NULL
</cfquery>
<cfset temp_data_min = round(query_x_fixed.some_field)>
测试在CF9工作
最简单的方法可能是只用那列进行查询,然后删除空格。
<cfquery name="query_x_fixed" dbtype="query">
SELECT some_field
FROM query_x
WHERE some_field IS NOT NULL
</cfquery>
<cfset temp_data_min= round(ArrayMin(query_x_fixed["some_field"]))>
(未经测试)
您可以将列转换为列表,然后转换为数组,将解决方案保留在一行。 ListToArray
默认忽略空列表项目,这是无效值的值。
<cfset temp_data_min = Round(ArrayMin(ListToArray(ValueList(query_x.some_field, Chr(7)), Chr(7))))>
这应比任何其他拟议解决办法更快,而且守则较少。
我已经指定了使用逗号作为数字小数分隔符的地方的分隔符。 如果您是在美国或者另一个使用“ ” 的地方, 您可以删除分隔符参数 。
使用的附加函数 :
An IE issue has me completely stumped. I have a coldfusion page that uses JQuery s AJAX .load function to load in a new flash file that is generated by coldFusion s cfchart tag. This works completely ...
I am getting ready to start a project that requires using OpenID within Coldfusion 8. I have found a number of different options and was wondering what has worked the best, get s the most support, ...
So this all began in trying to get Coldfusion9 portlets to run under Liferay, just like examples that I ve seen running JBOSS: http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSC00E3E9C-DC24-...
function getStateInfo(state){ alert(state); var f = new funcs(); f.setCallbackHandler(updateFormFieldStateInfo); f.setQueryFormat( column ); f.qry_getLenderEvictionStateInfo(<cfoutput>#...
Is there a way to find the elements generated by ColdFusion s <CFLayout> and <CFLayoutArea> tags? These tags: <cflayout type="tab" name="MyAccount"> <cflayoutarea name="...
Let me first say I am aware of this faq for Mach-II, which discusses using application specific mappings as a third option when: locating the framework in the server root is not possible and creating ...
I am upgrading from CF4.5 to CF8. Calls to COM dll s that used to work in version 4.5 now throw a "Complex object types cannot be converted to simple values.." error. The COM object has a few arrays ...
Sometimes it is necessary to write different code for Adobe ColdFusion vs Railo vs OpenBD, due to differences in implementation. Do people have a specific method that they use for this? For example, ...