Model Configuration
table()
Signature
Section titled “Signature”table() — returns void
Available in: model
Category: Miscellaneous Functions
Description
Section titled “Description”Use this method to tell Wheels what database table to connect to for this model.
You only need to use this method when your table naming does not follow the standard Wheels convention of a singular object name mapping to a plural table name.
To not use a table for your model at all, call table(false).
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
name | any | yes | — | Name of the table to map this model to. |
Examples
Section titled “Examples”// 1. Map the `User` model to a non-standard table name.
// In models/User.cfc
function config() {
// Tell Wheels to use `tbl_USERS` instead of the default `users` table.
table("tbl_USERS");
}
// 2. Map a model to a table with a legacy prefix.
// In models/Product.cfc
function config() {
table("legacy_products");
}
// 3. Declare a model that has no backing database table at all.
// In models/ApiResponse.cfc
function config() {
table(false);
}