php - Convert SQL to active record in CodeIgniter -


select *, sum(`relaxation_rating` + `food_rating`) ratings group code order ratings desc destinations 

how convert sql code cctiverecord in codeigniter?

i tried following methods, did show results.

$this->db->select("'(select *, sum(relaxation_rating + food_rating) database group code') ratings", false); $this->db->get("database");  

try:

$data = $this->db->select('*, sum(`relaxation_rating` + `food_rating`) ratings', false)->group_by('code')->order_by('ratings', 'desc')->get('destinations')->result_array(); 

or,

$this->db->select('*, sum(`relaxation_rating` + `food_rating`) ratings', false)->group_by('code')->order_by('ratings', 'desc')->get('destinations')->result(); 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -