-
Notifications
You must be signed in to change notification settings - Fork 194
Model Tags
Jeff Johns edited this page Feb 4, 2014
·
1 revision
Model | Extends | Table | Path |
---|---|---|---|
Tags_Model | Plain_Model | tags | /application/models/tags_model.php |
$this->load->model('tags_model', 'tags');
Property | Visibility | Default Value | Description |
---|---|---|---|
$sort | Public | name ASC | The default sort direction for reads. |
Called automatically which in turn calls the parent constructor and sets the model $data_types
properties.
Used to create new records in the tags table.
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. |
$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
}