We're going to create three models for this application; these are as follows:
discussions_model.php
: This helps in managing interactions with thediscussions
tablecomments_model.php
: This helps in managing interactions with thecomments
tableadmin_model.php
: This helps in managing interactions with theusers
table
The discussions_model.php
model file has three functions; these are fetch_discussions()
, fetch_discussion()
, and flag()
. The fetch_discussions()
function fetches many discussions, the fetch_discussion()
function fetches a single discussion, and the flag()
function sets a discussion as one that requires moderation by an admin.
The steps to create this model file are as follows:
Create the /path/to/codeigniter/application.models/discussion_model.php
file and add the following code to it:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Discussions_model extends CI_Model {...