Lucee ORM 没有数据源的 Session
Lucee ORM there is no Session for the datasource
我正在尝试在 Lucee 服务器中使用 ORM,但仍然出现错误 there is no Session for the datasource [mydatasource]
。数据源确实存在并且连接有效,已在管理员中验证并使用 cfquery 进行了测试。
这是application.cfc
<cfcomponent>
<cffunction name="onRequestStart" access="public" returntype="boolean" output="false">
<cfset this.datasource = "rift" />
<cfset this.ormEnabled = true />
<cfsetting showdebugoutput="false" />
<cfset this.ormsettings = { } />
<!---<cfset this.ormsettings.dbcreate = "dropcreate" />--->
<cfset this.ormsettings.logSQL = true />
<cfset ORMReload() />
<cfset testquery = ORMExecuteQuery("from test")>
<cfreturn true />
</cffunction>
</cfcomponent>
ORMSettings 应该在伪构造函数中定义,所以我相信这就是导致您出现问题的原因。
<cfcomponent output="false">
<!--- define orm settings --->
<cfset this.datasource = "rift" />
<cfset this.ormEnabled = true />
<cfset this.ormsettings.logSQL = true />
<cffunction name="onRequestStart" access="public" returntype="boolean" output="false">
<cfif StructKeyExists(url, "reload")>
<!--- you don't want to do this on every request --->
<cfset ORMReload() />
</cfif>
<cfset testquery = ORMExecuteQuery("from test")>
<cfreturn true />
</cffunction>
</cfcomponent>
还要确保您已将 cfc 命名为 test.cfc
并且它已设置为持久性。
我正在尝试在 Lucee 服务器中使用 ORM,但仍然出现错误 there is no Session for the datasource [mydatasource]
。数据源确实存在并且连接有效,已在管理员中验证并使用 cfquery 进行了测试。
这是application.cfc
<cfcomponent>
<cffunction name="onRequestStart" access="public" returntype="boolean" output="false">
<cfset this.datasource = "rift" />
<cfset this.ormEnabled = true />
<cfsetting showdebugoutput="false" />
<cfset this.ormsettings = { } />
<!---<cfset this.ormsettings.dbcreate = "dropcreate" />--->
<cfset this.ormsettings.logSQL = true />
<cfset ORMReload() />
<cfset testquery = ORMExecuteQuery("from test")>
<cfreturn true />
</cffunction>
</cfcomponent>
ORMSettings 应该在伪构造函数中定义,所以我相信这就是导致您出现问题的原因。
<cfcomponent output="false">
<!--- define orm settings --->
<cfset this.datasource = "rift" />
<cfset this.ormEnabled = true />
<cfset this.ormsettings.logSQL = true />
<cffunction name="onRequestStart" access="public" returntype="boolean" output="false">
<cfif StructKeyExists(url, "reload")>
<!--- you don't want to do this on every request --->
<cfset ORMReload() />
</cfif>
<cfset testquery = ORMExecuteQuery("from test")>
<cfreturn true />
</cffunction>
</cfcomponent>
还要确保您已将 cfc 命名为 test.cfc
并且它已设置为持久性。