有活动记录的COUNT?

时间:2018-05-04 03:15:37

标签: php codeigniter count

我在数据库中使用。但我想在CodeIgniter中使用。如何使用活动记录查询方法使用CodeIgniter执行此操作?可以用COUNT po_id来完成吗?

private int hWorked;
public int HoursWorked
{
    get
    {
        return hWorked;
    }
    set
    {
        hWorked = value;
    }
}

1 个答案:

答案 0 :(得分:0)

如果查询正确。请尝试此

$this->db->select('position.po_name AS position, activity.ac_name AS activity , COUNT(register.po_id) AS regis')
     ->from('register')
     ->join('activity', 'register.ac_id = activity.ac_id','INNER')
     ->join('position ', 'register.po_id = position.po_id','INNER')
     ->where('register.regis_status', 2)
     ->where('activity.ac_id', $ac_id)
     //more where ->where() 
     ->group_by('register.ac_id,register.po_id');