Model Class
findAllKeys()
Signature
Section titled “Signature”findAllKeys() — returns string
Available in: model
Category: Read Functions
Description
Section titled “Description”Returns all primary key values in a list.
In addition to quoted and delimiter you can pass in any argument that findAll() accepts.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
quoted | boolean | no | false | Set to true to enclose each value in single-quotation marks. |
delimiter | string | no | , | The delimiter character to separate the list items with. |
Examples
Section titled “Examples”// 1. Get a comma-delimited list of all primary key values for the Artist model
primaryKeyList = model("artist").findAllKeys();
// primaryKeyList -> "1,2,3,4,5"
// 2. Get keys for active artists only, enclosed in single quotes, separated by a pipe
primaryKeyList = model("artist").findAllKeys(quoted=true, delimiter="|", where="active=1");
// primaryKeyList -> "'1'|'3'|'5'"
// 3. Use the result directly in a SQL IN clause for a subsequent query
keyList = model("artist").findAllKeys(quoted=true, where="genreId=7");
albums = model("album").findAll(where="artistId IN (#keyList#)");