Skip to content

Model Object

updateProperty()

updateProperty() — returns boolean

Available in: model Category: CRUD Functions

Updates a single property and saves the record without going through the normal validation procedure. This is especially useful for boolean flags on existing records.

NameTypeRequiredDefaultDescription
propertystringno—Name of the property to update the value for globally.
valueanyno—Value to set on the given property globally.
parameterizeanynotrueSet to true to use cfqueryparam on all columns, or pass in a list of property names to use cfqueryparam on those only.
transactionstringno[runtime expression]Set this to commit to update the database, rollback to run all the database queries but not commit them, or none to skip transaction handling altogether.
callbacksbooleannotrueSet to false to disable callbacks for this method.
// 1. Set a boolean flag on an existing record (the primary use case)
product = model("Product").findByKey(56);
product.updateProperty("new", 1);

// 2. Mark a user account as active without triggering validations
user = model("User").findByKey(params.userId);
user.updateProperty("active", true);

// 3. Update a property and skip callbacks
post = model("Post").findByKey(params.id);
post.updateProperty(property="featured", value=true, callbacks=false);