Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 583

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

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
ColdFusion ORM
Example:
<cfset artist = EntityNew("Artist")>
<cfset artist.setFirstName("Marcia")>
<cfset artist.setlastName("Em")>
<cfset EntitySave(artist)>
Update objects
EntitySave
The method to update an object is the same as saving an object. Load the object that needs to be updated, make updates,
and save the object.
Syntax
EntitySave(entity, [forceinsert])
Example
The following example changes the first name of an artist with an Artist ID 1:
<cfset artist1 = EntityLoad("Artist", 1, true)>
<cfset artist1.setFirstName("Garcia")>
<cfset EntitySave(artist1)>
Read/Load objects
Entities are loaded using the
If the persistent CFC has an
Syntax
EntityLoad (entityname)
EntityLoad (entityname, id [, unique])
EntityLoad (entityname, filtercriteria [,unique]
EntityLoad(entityname, filtercriteria, sortorder [, options])
EntityLoadByExample(sampleentity [, unique])
EntityReload(entity)
Examples
EntityLoad (entityname)
Loads and returns an array of entities of the specified entity name. For example, to retrieve all the objects of the
"artist" CFC:
<cfset artist = EntityLoad('ARTIST')>
EntityLoad (entityname, id [, unique])
Loads and returns an entity whose Primary key's value is id. The entity is returned as an array by default. If unique
is true, then the entity is returned.
If the entity has a composite key, then the id has to be specified as key-value pairs (ColdFusion struct).
Example 1:
This example loads the Artist object with PK 100 and returns a single-element array containing the artist object.
<cfset artistArr = EntityLoad('Artist', 100)>
Example 2:
methods. All
EntityLoad
EntityLoad
method, the methods call the
init
Last updated 1/20/2012
methods take the entity name as input.
method while creating objects.
init
578

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents