Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 584

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
ColdFusion ORM
This example loads the Artist object with PK 100 and returns the artist object.
<cfset artistobj = EntityLoad('Artist', 100, true)>
Example 3:
This example loads the OrderDetail object which has the composite key OrderID=100 and ProductID=1 and
returns the orderdetail object.
<cfset orderDetail = EntityLoad('orderdetails', {OrderID=100, ProductID=1}, true)>
EntityLoad (entityname, filtercriteria [,unique]
Loads and returns an array of entities of the given entity name that matches the
is a key-value pair (ColdFusion struct) of property names and its values. If there are more than
filtercriteria
one key-value pair in
filtercriteria
exists that matches this
filtercriteria
of an array. If
unique=true
details of all artists that have state 'CA':
<cfset artistsFromCA = EntityLoad('Artist', {state="CA"})>
To retrieve a unique object, specify
occurs.
This example loads the artist object whose firstName is "Austin" and lastname is "Weber".
<cfset artist = EntityLoad('artist', {firstname="Austin", lastname="Weber"}, "true")>
EntityLoad(entityname,filtercriteria,sortorder[, options])
Loads and returns an array of entities that satisfy the
parameter.
is a key-value pair (ColdFusion struct) of property names and its values. If there are more than
filtercriteria
one key-value pairs in
filtercriteria
is a string, and should be specified in the following syntax:
sortorder
"propname1 asc, propname2 desc, ..."
Some examples of
sortorder
"firstname asc, lastname desc"
"firstname"
"country, age desc"
Example:
To retrieve artists whose state is CA, and sorted by City and FirstName:
<cfset artistsFromCA = EntityLoad('artist', {state="CA"}, "city asc, firstName")>
Certain configuration options can be input as name-value pairs as options argument. Several options can be
specified to control the behavior of entity retrieval.
: 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
, then they always use the AND operator. If you are sure that only one record
,
unique=true
and multiple records are returned, then an exception occurs. For example, to retrieve
. If more than one object satisfies the condition, an exception
unique= "true"
filtercriteria
, then they always use the AND operator.
are as follows:
Last updated 1/20/2012
filtercriteria
can be specified so that a single entity is returned instead
that is sorted as specified by the
579
.
sortorder

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents