因此時常我收到此錯誤,大多是由機器人引起:查詢不被列名的可轉位,但該列不應該存在
java.lang.IllegalArgumentException:
[Table (rows 0 columns ID, BOOKID, EDITIONID, EDITIONNAME, PRACTICEAREALINK, PUBLISHED):
...REALINK: [email protected]]
[PUBLISHED: [email protected]] ] is not indexable by webtypeid
但是要找到它指的是無處列在試圖引用的查詢中。
所以我們在這裏播放3個文件,一個index.cfm,一個Business.cfc和一個DAO.cfc。在業務代碼看起來像:
<cfcomponent extends="_lbr._core.NativeBusiness">
<cffunction name="init" access="public" output="false" returntype="_lbr._who._publication._Edition.EditionBusiness" hint="Pseudo-constructor">
<cfargument name="oEditionDAO" type="_lbr._who._publication._Edition.EditionDAO" required="true">
<cfscript>
super.init(argumentCollection=arguments);
variables.oEditionDAO = arguments.oEditionDAO;
return this;
</cfscript>
</cffunction>
<cffunction name="getEditionByPracticeArea" returntype="query" access="public">
<cfargument name="nEditionID" type="numeric" required="false">
<cfargument name="nPraciceAreaID" type="numeric" required="false">
<cfargument name="bPublished" type="boolean" required="false">
<cfscript>
return variables.oEditionDAO.getEditionByPracticeArea(argumentCollection=arguments);
</cfscript>
</cffunction>
<cffunction name="getEditionsByPracticeArea" returntype="query" access="public">
<cfargument name="nPracticeAreaID" type="numeric" required="false">
<cfargument name="bPracticeAreaLink" type="boolean" required="false">
<cfargument name="bPublished" type="boolean" required="false">
<cfargument name="lstFields" type="string" required="false">
<cfscript>
return variables.oEditionDAO.getEditionsByPracticeArea(argumentCollection=arguments);
</cfscript>
</cffunction>
<cffunction name="getTypesByPracticeArea" returntype="query" access="public">
<cfargument name="nPracticeAreaID" type="numeric" required="false">
<cfargument name="nEditionID" type="numeric" required="false">
<cfscript>
return variables.oEditionDAO.getTypesByPracticeArea(argumentCollection=arguments);
</cfscript>
</cffunction>
</cfcomponent>
沒有什麼特別不尋常的。
的DAO看起來像
<cfcomponent extends="_lbr._core.NativeDAO">
<cffunction name="init" access="public" output="false" returntype="_lbr._who._Publication._Edition.EditionDAO" hint="Pseudo-constructor">
<cfargument name="sDSN" type="string" required="true" hint="The datasource name to use to access the database through.">
<cfargument name="oCFML" type="_lbr._util._cfml.CFML" required="true" hint="The CFML object to use for scripting.">
<cfscript>
super.init(argumentCollection=arguments);
variables.sDSN = arguments.sDSN;
variables.oCFML = arguments.oCFML;
variables.lstFields = "p.publication_ID, p.publication_name, e.edition_id, e.edition_name, e.pub_year, e.pub_date";
variables.lstSubEditionFields = "id,bookid,editionid,editionname,practiceareaLink,published";
return this;
</cfscript>
</cffunction>
<cffunction name="getEditionByPracticeArea" returntype="query" access="public">
<cfargument name="nEditionID" type="numeric" required="false">
<cfargument name="nPraciceAreaID" type="numeric" required="false">
<cfargument name="bPublished" type="boolean" required="false">
<cfargument name="nStartRow" required="true" type="numeric" default="0">
<cfargument name="nEndRow" required="true" type="numeric" default="1">
<cfscript>
return selectEditionsByPracticeArea(argumentCollection=arguments);
</cfscript>
</cffunction>
<cffunction name="getEditionsByPracticeArea" returntype="query" access="public">
<cfargument name="nPracticeAreaID" type="numeric" required="false">
<cfargument name="bPracticeAreaLink" type="boolean" required="false">
<cfargument name="bPublished" type="boolean" required="false">
<cfargument name="lstFields" type="string" required="false">
<cfscript>
return selectEditionsByPracticeArea(argumentCollection=arguments);
</cfscript>
</cffunction>
<cffunction name="selectEditionsByPracticeArea" returntype="query" access="public">
<cfargument name="nStartRow" required="true" type="numeric" default="0">
<cfargument name="nEndRow" required="true" type="numeric" default="100">
<cfargument name="nEditionID" type="numeric" required="false" default="0">
<cfargument name="nPracticeAreaID" type="numeric" required="false" default="0">
<cfargument name="bPracticeAreaLink" type="boolean" required="false">
<cfargument name="bPublished" type="boolean" required="false">
<cfargument name="lstFields" type="string" default="#variables.lstSubEditionFields#" required="false">
<cfquery name="qQuery" datasource="#variables.sDSN#">
SELECT #arguments.lstFields#
FROM tbl_who_subeditions
WHERE 1
<cfif arguments.nPracticeAreaID gt 0>
AND bookid = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.nPracticeAreaID#">
</cfif>
<cfif arguments.nEditionID gt 0>
AND editionID = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.nEditionID#">
</cfif>
<cfif structKeyExists(arguments,"bPublished")>
AND published = <cfqueryparam cfsqltype="cf_sql_bit" value="#arguments.bPublished#">
</cfif>
<cfif arguments.nPracticeAreaID gt 0 OR arguments.nEditionID gt 0>
<cfif structKeyExists(arguments,"bPracticeAreaLink")>
AND practiceareaLink = <cfqueryparam cfsqltype="cf_sql_tinyint" value="#arguments.bPracticeAreaLink#">
</cfif>
</cfif>
LIMIT #arguments.nStartRow#,#arguments.nEndRow#
</cfquery>
<cfreturn qQuery>
</cffunction>
<cffunction name="getTypesByPracticeArea" returntype="query" access="public">
<cfargument name="nPracticeAreaID" type="numeric" required="false">
<cfargument name="nEditionID" type="numeric" required="false">
<cfscript>
return selectTypesByPracticeArea(argumentCollection=arguments);
</cfscript>
</cffunction>
<cffunction name="selectTypesByPracticeArea" returntype="query" access="public">
<cfargument name="nStartRow" required="true" type="numeric" default="0">
<cfargument name="nEndRow" required="true" type="numeric" default="100">
<cfargument name="nEditionID" type="numeric" required="false" default="0">
<cfargument name="nPracticeAreaID" type="numeric" required="false" default="0">
<cfargument name="lstFields" type="string" default="#variables.lstSubEditionFields#" required="false">
<cfquery name="qQuery" datasource="#variables.sDSN#">
SELECT distinct webtypeid, typename
FROM tbl_who_webtype2practiceareas wp
JOIN tbl_who_webtypes w ON wp.webtypeid = w.id
WHERE 1
<cfif arguments.nPracticeAreaID gt 0>
AND bookid = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.nPracticeAreaID#">
</cfif>
<cfif arguments.nEditionID gt 0>
AND editionid = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.nEditionID#">
</cfif>
LIMIT #arguments.nStartRow#,#arguments.nEndRow#
</cfquery>
<cfreturn qQuery>
</cffunction>
</cfcomponent>
這是不尋常這裏的唯一的事情就是selectTypesByPracticeArea
有一個lstFields違約與variables.lstSubEditionFields
,但因爲它沒有被在該函數中使用,它不應該證明一個問題
所以index.cfm只是有
variables.stArgs = {};
variables.stArgs.nPracticeAreaID = request.parameters.nPublicationID;
variables.stArgs.nEditionID = request.parameters.nSubEdition;
variables.qTypes = application.stObj.oEditionBusiness.getTypesByPracticeArea(argumentCollection=variables.stArgs);
if(variables.qTypes["webtypeid"].IndexOf(JavaCast("int",2)) GTE 0 OR variables.qTypes["webtypeid"].IndexOf(JavaCast("int",3)) GTE 0){
request.parameters.bHasTypes = true;
}
上發生的錯誤if語句。它應該只接收包含webtypeid
和typename
的查詢,那麼它在哪裏認爲它從ID, BOOKID, EDITIONID, EDITIONNAME, PRACTICEAREALINK, PUBLISHED
?我所能理解的是,它與前場混淆......但這沒有任何意義。
有錯誤處理代碼發送給您的變量cfdump。 qTypes – 2015-02-23 17:28:34