Model::setPrimary
Set Primary ID name
Description
public self Model::setPrimary( string $id )
The primary key is used by id, updateRow, delete, erase and the other methods that take an ID. Throws InvalidArgumentException when $id is not a plain name.
Arguments
| Name | Data type | Default | Remarks |
|---|---|---|---|
| $id | string | Primary key column name |
Example
Controller
$model = new Model();
$model->setPrimary('news_id');
// Same as the following
$model = new Model(false, array(
'id' => 'news_id',
));