Miscellaneous
primaryKey()
Signature
Section titled “Signature”primaryKey() — returns any
Description
Section titled “Description”Returns the name of the primary key for this model’s table. This is determined through database introspection. If composite primary keys have been used, they will both be returned in a list. This function is also aliased as primaryKeys().
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
position | numeric | yes | 0 | If you are accessing a composite primary key, pass the position of a single key to fetch. |
Examples
Section titled “Examples”primaryKey([ position ]) <!--- Get the name of the primary key of the table mapped to the `employee` model (which is the `employees` table by default) --->
<cfset keyName = model("employee").primaryKey()>