A little more background on my issue. I have a "Followers" sidebar on my site where users can follow other users. The problem is that currently the users that appear in this sidebar can also include users they already follow. I would like to modify the function so this no longer happens. Here is the model function that I currently use...
public function get_oldest($limit = 10, $user_id)
{
$this->db
->select($this->db->dbprefix('profiles').'.*, g.description as group_name, users.*')
->join('groups g', 'g.id = users.group_id')
->join('profiles', 'profiles.user_id = users.id', 'left')
->group_by('users.id');
$this->db->order_by('users.created_on', 'ASC');
$this->db->limit($limit);
$results = $this->db->get('users')->result_array();
return $results;
}
Here is the controller function...
function get_oldest() {
$this->load->model('user_account/user_account_m');
$limit = $this->attribute('limit');
$user_id = $this->current_user->id;
$users = $this->user_account_m->get_oldest($limit, $user_id);
return $users;
}
The "Follower"(default_follow) table in the sql database has the following structure...
id = the id of the follow event
follower_id = the user_id of the person who is doing the following
followed_id = the user_id of the person being followed
The "Profile"(default_profiles) table in the sql database has the following structure...
user_id
display_name
first_name
last_name
I know I need to use the current user's id in some way to get this to work, I'm just having a hard time figuring out how. Thanks in advance for your help people.