public
void create( category category )
CRUD method
Parameters:
Code:
<cffunction name="create" returntype="void" output="false" hint="CRUD method">
<cfargument name="category" type="machii_info_sample.model.category.category" required="yes" displayname="create" hint="I am the category from which to create a record" />
<cfset var categoryInsert = 0 />
<cfset var qry_lastCategory = 0 />
<cfquery name="categoryInsert" datasource="#variables.dsn#" >
INSERT INTO categories (
name,
sortOrder
) VALUES (
'#trim(arguments.category.getName())#',
<cfqueryparam cfsqltype="CF_SQL_BIGINT" value="#arguments.category.getSortOrder()#" >
)
</cfquery>
<cfquery name="qry_lastCategory" datasource="#variables.dsn#" >
SELECT categoryID
FROM categories
WHERE name = '#trim(arguments.category.getName())#'
</cfquery>
<cfset arguments.category.setCategoryID(qry_lastCategory.categoryID) >
<cfreturn />
</cffunction>