是否可以限制<cfquery dbtype="hql">
给出的结果(用于分页),例如Raymond Camden用EntityLoad
演示here?
<cfset items = entityLoad("person", {},url.sort & " " & url.sortdir, {maxresults=pageSize,offset=url.start-1})>
在我的情况下,使用简单的entityload()
无法请求对象,因为我需要检查一些事项:
<CFQUERY name="qEvents" dbtype="hql">
FROM events e
LEFT JOIN e.event_cat_id AS cat
LEFT JOIN cat.lang_id AS lang
WHERE lang.lang_id = <CFQUERYPARAM value="#session.lang_id()#" />
AND e.active = 1
AND (
(
DATE(e.date_begin) >= <CFQUERYPARAM value="#somedate#" cfsqltype="cf_sql_date" />
AND
DATE(e.date_begin) <= <CFQUERYPARAM value="#somedate#" cfsqltype="cf_sql_date" />
)
OR
(
DATE(e.date_end) >= <CFQUERYPARAM value="#somedate#" cfsqltype="cf_sql_date" />
AND
DATE(e.date_end) <= <CFQUERYPARAM value="#somedate#" cfsqltype="cf_sql_date" />
)
OR
(
DATE(e.date_begin) >= <CFQUERYPARAM value="#somedate#" cfsqltype="cf_sql_date" />
AND
DATE(e.date_end) <= <CFQUERYPARAM value="#somedate#" cfsqltype="cf_sql_date" />
)
OR
(
DATE(e.date_begin) <= <CFQUERYPARAM value="#somedate#" cfsqltype="cf_sql_date" />
AND
DATE(e.date_end) >= <CFQUERYPARAM value="#somedate#" cfsqltype="cf_sql_date" />
)
)
GROUP BY e.event_id
ORDER BY e.date_begin
</CFQUERY>
我知道maxrow
有一个<cfquery>
- 属性,但这并不是我需要的。
答案 0 :(得分:5)
使用ormoptions属性
<cfquery name="" dbtype="hql" ormoptions="#{maxresults=pageSize,offset=url.start-1}#"