-<!--- PUBLIC MODEL CLASS METHODS --->
+<cfscript>
+	/*
+	* PUBLIC MODEL CLASS METHODS
+	*/
 
-<cffunction name="updateAll" returntype="numeric" access="public" output="false">
-	<cfargument name="where" type="string" required="false" default="">
-	<cfargument name="include" type="string" required="false" default="">
-	<cfargument name="properties" type="struct" required="false" default="#StructNew()#">
-	<cfargument name="reload" type="boolean" required="false">
-	<cfargument name="parameterize" type="any" required="false">
-	<cfargument name="instantiate" type="boolean" required="false">
-	<cfargument name="validate" type="boolean" required="false" default="true">
-	<cfargument name="transaction" type="string" required="false" default="#application.wheels.transactionMode#">
-	<cfargument name="callbacks" type="boolean" required="false" default="true">
-	<cfargument name="includeSoftDeletes" type="boolean" required="false" default="false">
-	<cfscript>
-		var loc = {};
+	public numeric function updateAll(
+		string where="",
+		string include="",
+		struct properties="#StructNew()#",
+		boolean reload,
+		any parameterize,
+		boolean instantiate,
+		boolean validate="true",
+		string transaction="#application.wheels.transactionMode#",
+		boolean callbacks="true",
+		boolean includeSoftDeletes="false"
+	) {
 		$args(name="updateAll", args=arguments);
 		arguments.include = $listClean(arguments.include);
 		arguments.where = $cleanInList(arguments.where);

		{
			arguments.sql = [];
			ArrayAppend(arguments.sql, "UPDATE #tableName()# SET");
			loc.pos = 0;
			for (loc.key in arguments.properties)
			{
				loc.pos++;
				ArrayAppend(arguments.sql, "#variables.wheels.class.properties[loc.key].column# = ");
				loc.param = {value=arguments.properties[loc.key], type=variables.wheels.class.properties[loc.key].type, dataType=variables.wheels.class.properties[loc.key].dataType, scale=variables.wheels.class.properties[loc.key].scale, null=!Len(arguments.properties[loc.key])};
				ArrayAppend(arguments.sql, loc.param);
				if (StructCount(arguments.properties) > loc.pos)
				{
					ArrayAppend(arguments.sql, ",");
				}
			}
			arguments.sql = $addWhereClause(sql=arguments.sql, where=arguments.where, include=arguments.include, includeSoftDeletes=arguments.includeSoftDeletes);
			arguments.sql = $addWhereClauseParameters(sql=arguments.sql, where=arguments.where);
			loc.rv = invokeWithTransaction(method="$updateAll", argumentCollection=arguments);
		}
	</cfscript>
	<cfreturn loc.rv>
</cffunction>

<cffunction name="updateByKey" returntype="boolean" access="public" output="false">
	<cfargument name="key" type="any" required="true">
	<cfargument name="properties" type="struct" required="false" default="#StructNew()#">
	<cfargument name="reload" type="boolean" required="false">
	<cfargument name="validate" type="boolean" required="false" default="true">
	<cfargument name="transaction" type="string" required="false" default="#application.wheels.transactionMode#">
	<cfargument name="callbacks" type="boolean" required="false" default="true">
	<cfargument name="includeSoftDeletes" type="boolean" required="false" default="false">
	<cfscript>
		var loc = {};
		$args(name="updateByKey", args=arguments);
		$keyLengthCheck(arguments.key);
		arguments.where = $keyWhereString(values=arguments.key);
		StructDelete(arguments, "key");
		loc.rv = updateOne(argumentCollection=arguments);
	</cfscript>
	<cfreturn loc.rv>
</cffunction>

<cffunction name="updateOne" returntype="boolean" access="public" output="false">
	<cfargument name="where" type="string" required="false" default="">
	<cfargument name="order" type="string" required="false" default="">
	<cfargument name="properties" type="struct" required="false" default="#StructNew()#">
	<cfargument name="reload" type="boolean" required="false">
	<cfargument name="validate" type="boolean" required="false" default="true">
	<cfargument name="transaction" type="string" required="false" default="#application.wheels.transactionMode#">
	<cfargument name="callbacks" type="boolean" required="false" default="true">
	<cfargument name="includeSoftDeletes" type="boolean" required="false" default="false">
	<cfscript>
		var loc = {};
		$args(name="updateOne", args=arguments);
		loc.object = findOne(where=arguments.where, order=arguments.order, reload=arguments.reload, includeSoftDeletes=arguments.includeSoftDeletes);
		StructDelete(arguments, "where");
		StructDelete(arguments, "order");
		if (IsObject(loc.object))
		{
			loc.rv = loc.object.update(argumentCollection=arguments);
		}
		else
		{
			loc.rv = false;
		}
	</cfscript>
	<cfreturn loc.rv>
</cffunction>

<!--- PUBLIC MODEL OBJECT METHODS --->

<cffunction name="update" returntype="boolean" access="public" output="false">
	<cfargument name="properties" type="struct" required="false" default="#StructNew()#">
	<cfargument name="parameterize" type="any" required="false">
	<cfargument name="reload" type="boolean" required="false">
	<cfargument name="validate" type="boolean" required="false" default="true">
	<cfargument name="transaction" type="string" required="false" default="#application.wheels.transactionMode#">
	<cfargument name="callbacks" type="boolean" required="false" default="true">
	<cfscript>
		var loc = {};
		$args(name="update", args=arguments);
		$setProperties(argumentCollection=arguments, filterList="properties,parameterize,reload,validate,transaction,callbacks");
		loc.rv = save(parameterize=arguments.parameterize, reload=arguments.reload, validate=arguments.validate, transaction=arguments.transaction, callbacks=arguments.callbacks);
	</cfscript>
	<cfreturn loc.rv>
</cffunction>

<cffunction name="updateProperty" returntype="boolean" access="public" output="false">
	<cfargument name="property" type="string" required="false">
	<cfargument name="value" type="any" required="false">
	<cfargument name="parameterize" type="any" required="false">
	<cfargument name="transaction" type="string" required="false" default="#application.wheels.transactionMode#">
	<cfargument name="callbacks" type="boolean" required="false" default="true">
	<cfscript>
		var loc = {};
		$args(name="updateProperty", args=arguments);
		arguments.reload = false;
		arguments.validate = false;
		if (StructKeyExists(arguments, "property") && StructKeyExists(arguments, "value")) {

		// find and instantiate each object and call its update function
		if (arguments.instantiate)
		{
			local.rv = 0;
			local.objects = findAll(where=arguments.where, include=arguments.include, reload=arguments.reload, parameterize=arguments.parameterize, callbacks=arguments.callbacks, includeSoftDeletes=arguments.includeSoftDeletes, returnIncluded=false, returnAs="objects");
			local.iEnd = ArrayLen(local.objects);
			for (local.i=1; local.i <= local.iEnd; local.i++)
			{
				if (local.objects[local.i].update(properties=arguments.properties, parameterize=arguments.parameterize, transaction=arguments.transaction, callbacks=arguments.callbacks))
				{
					local.rv++;
				}
			}
		}
