SELECT SQL_CALC_FOUND_ROWS
						mobiles.id AS mobile_id,
						mobiles.model AS mobile_model,
						mobiles.safe_name AS mobile_safe_name,		
						mobiles.merged_features_tags AS mobile_merged_features_tags,						
						mobiles.votes AS mobiles_votes,
						mobiles.rating AS mobiles_rating,	
						mobiles.product_type_id,
						brand_options.name AS brand_name,	
						brand_options.safe_name AS brand_safe_name,	
						mobiles.deal_count,	
						mobiles.min_ec,
						mobiles.review_count,
						mobiles.video_url,
						os_versions.name as os_version_name,				
						(IF (tags.name != 'coming soon' AND tags.name != 'discontinued' AND tags.name != 'never released', CONCAT('Released in ', tags.name), tags.name)) AS group_field
					 FROM mobiles
						LEFT JOIN brand_options ON brand_options.id = mobiles.brand_option_id   
						LEFT JOIN os_versions ON os_versions.id = mobiles.os_version_id   
						 INNER JOIN (SELECT mobiles.id, COUNT(*) AS c FROM mobiles
							INNER JOIN tagging ON mobiles.id = tagging.taggable_id
						WHERE tagging.type_id = 1 AND tag_id = '29'  GROUP BY mobiles.id ) AS mobiles_tags ON mobiles_tags.id = mobiles.id   INNER JOIN tagging ON mobiles.id = tagging.taggable_id AND tagging.type_id = 1  INNER JOIN tags ON tags.id = tagging.tag_id AND tags.tag_group_id = 5
						WHERE 1  AND mobiles.VISIBLE = 1  AND brand_options.VISIBLE = 1  AND mobiles.BRAND_OPTION_ID='104' AND mobiles.PRODUCT_TYPE_ID='1' AND  mobiles_tags.c = 1 ORDER BY tags.priority ASC, tags.name ASC LIMIT 50
/home/mobile/public_html/lib/model/ProductsPeer.php 565