Model Tags
| Model | Extends | Table | Path |
|---|---|---|---|
| Tags_Model | Plain_Model | tags | /application/models/tags_model.php |
Loading the model
$this->load->model('tags_model', 'tags');
Properties
| Property | Visibility | Default Value | Description |
|---|---|---|---|
| $sort | Public | name ASC | The default sort direction for reads. |
Methods
__construct - Public
Called automatically which in turn calls the parent constructor and sets the model $data_types properties.
create - Public
Used to create new records in the tags table.
Arguments
| Variable | Type | Default | Required | Description |
|---|---|---|---|---|
| $options | array | array() | Yes | An associative array that contains the column names and the values for the record to be created. Array keys are the column names for each value. |
| $options['name'] | string | N/A/td> | Yes | The tag name. |
Example
$this->load->model('tags_model', 'tags'); $tag = $this->tags->create(array('name' => $name)); // If tag was created if (isset($tag->tag_id)) { // Good to go } // Some sort of validation error elseif (isset($tag['errors']) { // Validation errors were found } // Some sort of database write error, check logs else { // will return false }