开发者

Codeigniter active record help or mysql help

I have this syntax for grabbing some data from database, I using codeigniter's active record,

$this->db->select('job_id, jobs.employer_id, company_job_id, like_job_id, logo, company_name')
        ->from('jobs')
        ->join('company_likes', 'company_likes.like_job_id = jobs.job_id', 'left')
        ->join('company_views', 'company_views.company_job_id = jobs.job_id', 'left')
        ->join('employers', 'employers.employer_id = jobs.employer_id', 'left');

        $query = $this->db->get();

        return $query->result_array();

No this should be return 1 result however, it is returning 4 records as that is the number of records in the company_views table, what I am wanting to achieve is that I get returned the number of views in the databsae for that employer, but I only want to do it using one query.

Currently this q开发者_运维百科uery is used to get the employer details to the user, but I also want to feed back how many times the emloyer has been viewed.


try adding $this->db->group_by('company_views.company_job_id')

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜