我正在使用codeigniter,但无法为控制器编写代码

I want to send the message to agents about the total properties that his clients had, for this I am joining 3 tables. I had agent id at agents table and total properties in activity_search_log . so I got done with a model as below My code in model is:

public function agentsjoin(){
    $this->db->select('*');
    $this->db->from('agents ');
    $this->db->sum('prop_nums')
    $this->db->limit (100);
    $query=$this->db->get();
    $list=$query->result();
    return $list;
}

In controller, I want design code in such a way that and unable to write:

foreach(agent)
    if(properties > 0)
        send message;
    else
        no props exist to send message;