Return to v1.4.5 docs

save()



Saves the object if it passes validation and callbacks. Returns true if the object was saved successfully to the database, false if not.

Name Type Required Default Description
parameterize any No true See documentation for findAll.
reload boolean No false Set to true to reload the object from the database once an insert/update has completed.
validate boolean No true Set to false to skip validations for this operation.
transaction string No Set this to commit to update the database when the save has completed, rollback to run all the database queries but not commit them, or none to skip transaction handling altogether.
callbacks boolean No true Set to false to disable callbacks for this operation.
<!--- Save the user object to the database (will automatically do an `INSERT` or `UPDATE` statement depending on if the record is new or already exists --->
<cfset user.save()>

<!--- Save the user object directly in an if statement without using `cfqueryparam` and take appropriate action based on the result --->
<cfif user.save(parameterize=false)>
	<cfset flashInsert(notice="The user was saved!")>
	<cfset redirectTo(action="edit")>
<cfelse>
	<cfset flashInsert(alert="Error, please correct!")>
	<cfset renderPage(action="edit")>
</cfif>