Adobe COLDFUSION 9 Manual page 581

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

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
ColdFusion ORM
boolean Has<relationship_property_name>()
This method is generated for all the relationships. For one-to-many and many-to-many, this method checks
whether the association collection is empty. If the association collection is empty, it will return true. For one-to-one
and many-to-one, this method checks whether the associated object exists.
boolean Has<relationship_property_name>(<associated_object>)
This method is generated for one-to-many and many-to-many relationships. The method checks whether the given
associated object is present in the association collection. If it is present, it returns true.
For
, the method signature is
type="array"
boolean has<relationship_property_name>(<associated_object>)
For
, the method signature is
type="struct"
boolean has<relationship_property_name>(<key>)
Example
Consider the following example of artists (ARTISTS table) and artwork (ART table), where the artist forms a one-to-
many relationship with artwork.
Artist.cfc
<cfcomponent persistent="true" schema="APP" table="Artists">
<cfproperty name="artistid" fieldtype="id"/>
<cfproperty name="firstname"/>
<cfproperty name="lastname"/>
<cfproperty name="state"/>
<cfproperty name="art" fieldtype="one-to-many" cfc="Art" fkcolumn="ArtistID" >
</cfcomponent>
Art.cfc
<cfcomponent persistent="true" schema="APP" table="Art">
<cfproperty name="artid" fieldtype="id"/>
<cfproperty name="artname"/>
<cfproperty name="issold"/>
</cfcomponent>
In this example Artist has a relation field
• addArts(Art art)
• booleanremoveArts(Art art)
• booleanhasArts()
• booleanhasArts(Art art)
The attribute
singularName
example, if the relationship property of Artist is specified as follows:
<cfproperty name="art" fieldtype="one-to-many" cfc="Art" fkcolumn="ArtistID"
singularName="Art">
then the following methods are generated:
• addArt(Art art)
• removeArt(Art art)
• hasArt()
with Art. The following methods are implicitly added to the Artist object:
art
provides the flexibility to change the name of the generated relationship methods. For
Last updated 8/5/2010
576

Advertisement

Table of Contents
loading

Table of Contents