function actionSearch() { header('Content-type: application/json'); // if(Yii::app()->user->isGuest){ // IjoyPlusServiceUtils::exportServiceError(Constants::SEESION_IS_EXPIRED); // return ; // } if (!IjoyPlusServiceUtils::validateAPPKey()) { IjoyPlusServiceUtils::exportServiceError(Constants::APP_KEY_INVALID); return; } $keyword = Yii::app()->request->getParam("keyword"); if (!(isset($keyword) && !is_null($keyword) && strlen($keyword) > 0)) { IjoyPlusServiceUtils::exportServiceError(Constants::KEYWORD_IS_NULL); return; } $keyword = trim($keyword); Lookup::model()->saveLookup($keyword); if (!FilterUtils::keyWordValid($keyword)) { IjoyPlusServiceUtils::exportEntity(array('results' => array())); return; } // $keyword= iconv("GBK","UTF-8",$keyword);n // var_dump($keyword); //$keyword='???'; // var_dump($keyword); $keyword = strtr($keyword, array('%' => '\\%', '_' => '\\_')); // var_dump($keyword); $page_size = Yii::app()->request->getParam("page_size"); $page_num = Yii::app()->request->getParam("page_num"); if (!(isset($page_size) && is_numeric($page_size))) { $page_size = 10; $page_num = 1; } else { if (!(isset($page_num) && is_numeric($page_num))) { $page_num = 1; } } $type = Yii::app()->request->getParam("type"); try { if (is_null($type) || $type == '') { $prods = SearchManager::searchProgram($keyword, $page_size, $page_size * ($page_num - 1)); } else { $prods = SearchManager::searchProgramByType($keyword, $type, $page_size, $page_size * ($page_num - 1)); } if (isset($prods) && is_array($prods)) { IjoyPlusServiceUtils::exportEntity(array('results' => $prods)); } else { IjoyPlusServiceUtils::exportEntity(array('results' => array())); } } catch (Exception $e) { var_dump($e); IjoyPlusServiceUtils::exportServiceError(Constants::SYSTEM_ERROR); } }