You are viewing documentation for v1.1.x. Change

setPrimaryKey()

Description

Allows you to pass in the name(s) of the property(s) that should be used as the primary key(s). Pass as a list if defining a composite primary key. Also aliased as setPrimaryKeys().

Function Syntax

setPrimaryKey(property)

Parameters

Parameter Type Required Default Description
property string Yes Property (or list of properties) to set as the primary key.

Examples

<!--- In `models/User.cfc`, define the primary key as a column called `userID` --->
<cffunction name="init">
    <cfset setPrimaryKey("userID")>
</cffunction>