public function actionAppInfoList() { $limit = Yii::app()->request->getParam('limit'); $offset = Yii::app()->request->getParam('offset'); $os = Yii::app()->request->getParam('os'); $appName = Yii::app()->request->getParam('app_name'); $mainCategory = Yii::app()->request->getParam('main_category'); $subcategory = Yii::app()->request->getParam('subcategory'); if (!(is_numeric($limit) && is_numeric($offset))) { $limit = 10; $offset = 0; } $where = 'a.Status = 0'; if ($appName) { $where .= ' AND a.AppName like "%' . $appName . '%"'; } if ($os) { $where .= ' AND s.OS = "' . addslashes($os) . '"'; } if ($mainCategory && !$subcategory) { $categoryModel = new Category(); $where .= ' AND a.MainCategory ' . $categoryModel->getCategoryCondition($mainCategory); } if ($subcategory && $mainCategory) { $where .= ' AND a.MainCategory = ' . $subcategory; } $list = Yii::app()->db->createCommand()->select('a.Id, a.IconUrl, a.AppName, c.ID as categoryID, c.Name as subcategory, s.OS, a.UpdateTime')->from('app_info_list a')->join('source s', 'a.SourceId = s.ID')->join('category c', 'a.MainCategory = c.ID')->where($where)->order('Id' . ' desc')->limit($limit, $offset)->queryAll(); $data = array(); $categoryModel = new Category(); foreach ($list as $row) { $row['mainCategory'] = $categoryModel->getMainCategory($row['categoryID']); $data[] = $row; } echo new ReturnInfo(0, $data); }