hasChanged()
Description
Returns true if the specified object property (or any if none was passed in) have been changed but not yet saved to the database. Will also return true if the object is new and no record for it exists in the database.
Function Syntax
hasChanged([ property ])
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
property |
string |
No | |
Name of property to check for change. |
Examples
<!--- Get a member object and change the `email` property on it --->
<cfset member = model("member").findByKey(params.memberId)>
<cfset member.email = params.newEmail>
<!--- Check if the `email` property has changed --->
<cfif member.hasChanged(property="email")>
<!--- Do something... --->
</cfif>
<!--- The above can also be done using a dynamic function like this --->
<cfif member.emailHasChanged()>
<!--- Do something... --->
</cfif>
