Adobe COLDFUSION 9 Manual page 587

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
ColdFusion ORM
ORMExecuteQuery(hql, [,unique] [, queryoptions])
Runs the HQL on the default data source specified for the application. You can specify several options to control the
behavior of retrieval using queryoptions:
: Specifies the maximum number of objects to be retrieved.
maxResults
: Specifies the start index of the resultset from where it has to start the retrieval.
offset
: Whether the result of this query is to be cached in the secondary cache. Default is false.
cacheable
: Name of the cache in secondary cache.
cachename
: Specifies the timeout value (in seconds) for the query
timeout
and
are used for pagination.
Maxresults
timeout
Note: If the query returns an object or an array of objects, the
Examples
To retrieve an array of artwork objects from the ART table:
<cfset art = ORMExecuteQuery("from ART")>
To retrieve an array of artwork objects that have a price greater than 400 dollars:
<cfset art = ORMExecuteQuery("from ART where price > 400")>
To retrieve an array of artwork objects that have a priceid 100:
<cfset artObj = ORMExecuteQuery("from ART where priceid = 100>
To retrieve an array of objects that contain the first name of artists:
<cfset firstNameArray = ORMExecuteQuery("select FirstName from Artist")>
To retrieve the number of artwork objects:
<cfset numberOfArts = ORMExecuteQuery("select count(*) from Art")>
To retrieve an array of objects that have an artistid 1:
<cfset firstName = ORMExecuteQuery("select FirstName from Artist where ARTISTID = 1", true)>
To retrieve an array of ten artist objects starting from the fifth row in the query result:
<cfset artists = ORMExecuteQuery("from Artist", false, {offset=5, maxresults=10, timeout=5})>
ORMExecuteQuery(hql, params [,unique] [,queryOptions])
This type of
ORMExecuteQuery
holder for the parameters. The values to the parameters should be passed as an array to
Examples: unnamed parameters
To retrieve an array of artist objects with artistid equal to 40:
<cfset artists = ORMExecuteQuery("from ARTIST where artistid > ?", [40])>
To retrieve an array of artwork objects with a priceid equal to 1:
<cfset artObj = ORMExecuteQuery("from ART where priceid=?", [1], true)>
To retrieve an array of objects with a price id equal to 40, and price lesser than 80 dollars:
<cfset artists = ORMExecuteQuery("from ART where priceid > ? and price < ?", [40, 80])>
lets you pass unnamed parameters to the query. Use '?' (question mark) as the place-
Last updated 8/5/2010
method of the persistent CFC is called (if available).
init
params
582
.

Advertisement

Table of Contents
loading

Table of Contents