com.sebtools Build 12 Documentation: Records.cfc

Records.cfc

Records.cfc is service component built to handle a single type of data (usually one table in the database). It uses Manager.cfc and can work on any database supported by DataMgr.

Whereas other components in the com.sebtools package are typically used by composition (they is, they are passed in to components that use them), Records.cfc is meant to be extended. As Records.cfc components use Manager.cfc, Manager.cfc must be aware of any data set being used by the Records.cfc component.

This can be done either using the "xml" method of Records.cfc or by setting variables.table to the name of a table that has previously been defined.

Examples

This is Photos.cfc with the table defined using the "xml" method:

<cfcomponent displayname="Photos" extends="com.sebtools.Records">

<cffunction name="xml" access="public" output="yes">
<tables>
	<table name="photos" entity="Photo" Specials="CreationDate,LastUpdatedDate,Sorter">
		<field
			name="PhotoImage"
			Label="Image"
			type="image"
			Folder="photos"
			MaxWidth="200"
			MaxHeight="120"
			required="true"
		/>
	</table>
</tables>
</cffunction>

</cfcomponent>

This XML would define a table named "photos" with the following fields:

If, however, the XML for the "photos" table has been passed to Manager.cfc outside of the component, then Photos.cfc could be the following:

<cfcomponent displayname="Photos" extends="com.sebtools.Records">

<cfset variables.table = "photos">

</cfcomponent>
In fact, the Photos.cfc component could be skipped altogether and a reference could be created by instantiating the component passing in the table as an argument.
<cfset Application.Photos = CreateObject("component","com.sebtools.Records").init(Manager=Application.Manager,table="photos")>

The component will work the same regardless of which of the above techniques are used.