getter 函数需要在 ORM 组件中使用吗?

Do getter functions need to be used within an ORM component?

在 ORM 函数中使用内部 ORM 属性时是否必须使用 getter 函数?例如在下面的示例中我使用#person_id# 而不是 this.getperson_id().

<cfcomponent persistent="true" table="people" schema="dbo" output="false">
<cfproperty name="person_id" column="person_id" type="numeric" ormtype="int"fieldtype="id"/>

<cffunction name= "hasGifts" returntype="boolean">
<cfset gift_count = ORMExecuteQuery("SELECT COUNT(g.gift_id) FROM gifts g INNER JOIN g.people p WHERE p.person_id = '#person_id#', True )>
<cfif gift_count eq 0>
    <cfreturn false>
<cfelse>
    <cfreturn true>
</cfif>
</cffunction>

这似乎工作正常,但我没有找到它的文档。似乎应该允许,因为没有歧义,这与其他语言一致。

AFAIK 可以直接引用变量,只要它们不是惰性加载的。不过,您的 ORMExecuteQuery() 应该使用 :named? 位置绑定值。