![]() |
HI GUYS Suggest me - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: HI GUYS Suggest me (/showthread.php?tid=12785) |
HI GUYS Suggest me - El Forum - 10-31-2008 [eluser]Shahgeb[/eluser] Actually I want to make it clear this thing that below Two query are given. is there any overhead for server to excecute query.? what will be efficient exection of query.? Query 1 $query = 'select n.id, n.title as newsTitle, n.short_description, n.news_slug, c.id as catId, c.name as categoryName, ig.image_name from news n, tpaper_current_news cn LEFT JOIN news_image ni ON (cn.news_id = ni.news_id) LEFT JOIN image_gallery ig ON (ni.image_id = ig.id), category c, news_category nc where cn.type = "breaking" AND cn.status = "Active" AND cn.news_id = n.id AND cn.news_id = nc.news_id AND nc.category_id = c.id AND n.date_publish like "%'.$date.'%" '; if($is_tpaper != '') { $query .= ' AND n.is_tpaper = "'.$is_tpaper.'" '; } $query .= ' order by cn.sort_order DESC '; if($no_of_news != '') { $query .= 'LIMIT 0 , '.$no_of_news; //n.date_publish DESC, } return $this->db->query($query); Query 2 $conditions = array( 'cn.type' => 'breaking', 'cn.status' => 'Active' ); $like = array( 'n.date_publish' => $date ); $param = 'n.id, n.title as newsTitle, n.short_description, n.news_slug,c.id as catId, c.name as categoryName'; if($date != '') { if(!empty($where)) $this->db->where($where); $this->db->select($param)-> from('tpaper_current_news cn')-> join('news n','cn.news_id = n.id')-> join('news_category nc','n.id = nc.news_id')-> join('category c', 'nc.category_id = c.id'); if(!empty($conditions)) $this->db->where($conditions); if(!empty($like)) $this->db->like($like); if($is_tpaper != '') $this->db->where('n.is_tpaper', $is_tpaper); $this->db->order_by('n.id', 'DESC')-> limit(5, 0); return $this->db->get(); |