Skip to content

Model User Marks To Tags

Jeff Johns edited this page Feb 4, 2014 · 2 revisions
Model Extends Table Path
User_Marks_To_Tags_Model Plain_Model user_marks_to_tags /application/models/user_marks_to_tags_model.php

Loading the model

$this->load->model('user_marks_to_tags_model', 'umtt');

Properties

Property Visibility Default Value Description
$sort Public user_marks_to_tag_id DESC 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 user marks to 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['tag_id'] integer N/A/td> Yes The tag id.
$options['user_id'] integer N/A/td> Yes The user id.
$options['users_to_mark_id'] integer N/A/td> Yes The user mark id.

Example

$this->load->model('user_marks_to_tags_model', 'umtt');
$umtt = $this->umtt->create(array('tag_id' => 7, 'user_id' => $this->user_id, 'user_to_mark_id' => 144));

// If tag was created
if (isset($umtt->user_id)) {
    // Good to go
}

// Some sort of validation error
elseif (isset($umtt['errors']) {
    // Validation errors were found
}

// Some sort of database write error, check logs
else {
    // will return false
}

delete - Public

One of the rare occurences of an actual delete.

Arguments

Variable Type Default Required Description
$where string N/A Yes The where clause for the delete query.

Example

$this->load->model('user_marks_to_tags_model', 'umtt');
if ($this->umtt->delete("user_id = '" . $this->user_id . "'") === true) {
    // Shiz got deleted for that user
}

getMostRecent - Public

Returns the most recently used tags for a user.

Arguments

Variable Type Default Required Description
$user_id integer N/A Yes The user_id to get the list for.
$limit integer 10 No The total number of tags to retrieve.

Example

$this->load->model('user_marks_to_tags_model', 'umtt');
$recent = $this->umtt->getMostRecent($this->user_id);

getPopular - Public

Returns the most popular tags for a user.

Arguments

Variable Type Default Required Description
$user_id integer N/A Yes The user_id to get the list for.
$limit integer 10 No The total number of tags to retrieve.

Example

$this->load->model('user_marks_to_tags_model', 'umtt');
$popular = $this->umtt->getPopular($this->user_id);

getTagList - Private

Used by getMostRecent and getPopular to retrieve the correct records.

Arguments

Variable Type Default Required Description
$user_id integer N/A Yes The user_id to get the list for.
$limit integer 10 No The total number of tags to retrieve.
$type string N/A Yes Either popular or recent.

Example

return self::getTagList($user_id, $limit, 'popular');g