save()
Description
Saves the object if it passes validation and callbacks. Returns true if the object was saved successfully to the database, false if not.
Function Syntax
save([ parameterize, defaults, validate ])
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
parameterize |
any |
No | true |
Accepts a boolean value or a string. Set to true to use cfqueryparam on all columns or pass in a list of property names to use cfqueryparam on those only. |
defaults |
boolean |
No | true |
Whether or not to set default values for properties. |
validate |
boolean |
No | true |
Whether or not to run validations when saving |
Examples
<!--- 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="userEdit")>
<cfelse>
<cfset flashInsert(alert="Error, please correct!")>
<cfset renderPage(action="userEdit")
</cfif>
