public function actionDropList() { $dataFormat = new DataFormat(); $currentCity = UserRefreshForm::model()->getCurrentCity(); $criteria1 = new CDbCriteria(); $criteria2 = new CDbCriteria(); $criteria3 = new CDbCriteria(); $dropListModel = DropList::model(); $dropListData1 = null; $dropListData2 = null; $dropListData3 = null; $format2 = array(); $format3 = array(); $format1 = array(); if (isset($_POST['DropList']['secenicName']) && !empty($_POST['DropList']['secenicName'])) { $secenicName = $_POST['DropList']['secenicName']; $criteria1->addSearchCondition(' secenicName', $secenicName); $criteria1->addCondition("cityName='{$currentCity}'"); $dropListData1 = $dropListModel->findAll($criteria1); $format1 = $dataFormat->format($dropListData1, null); if (count($format1) <= 0) { //匹配整个数据库 $criteria2->addSearchCondition(' secenicName', $secenicName); $dropListData2 = $dropListModel->findAll($criteria2); //分词 $scws = new SCWS(); $scws->sendMobile($secenicName); $param1 = $scws->result[0]; if ($param1 != null) { $criteria3->addCondition("cityName='{$param1}'"); } if (count($scws->result) > 1) { $param2 = $scws->result[1]; $criteria3->addSearchCondition(' secenicName', $param2); } // $total = $dropListModel->count($criteria); // $pager = new CPagination($total); // $pager->pageSize = 100; // $pager->applyLimit($criteria); $dropListData3 = $dropListModel->findAll($criteria3); $format2 = $dataFormat->format($dropListData2, null); $format3 = $dataFormat->format($dropListData3, null); } $format = array_merge($format1, $format2, $format3); //去除重复的ID if (count($format) > 0) { $this->sendMobile(0, $format); } else { $this->sendMobile(3, '数据为空'); } } else { $this->sendMobile(1, '数据错误'); } $this->render('dropList', array('dropList' => $dropListModel)); }
public function actionFind() { if (isset($_POST['flightNumber'])) { $current = date('Y-m-d'); $flightNumber = $_POST['flightNumber']; $criteria = new CDbCriteria(); $criteria->join = 'LEFT JOIN tbl_mry_user ON tbl_mry_plan.userId=tbl_mry_user.userId'; $criteria->addCondition('flightNumber=:flightNumber'); $criteria->params = array(':flightNumber' => $flightNumber); $criteria->order = 'startDate DESC'; $UserModel = User::model(); $total = $UserModel->count($criteria); $pager = new CPagination($total); $pager->pageSize = 10; $pager->applyLimit($criteria); $UserList = $UserModel->findAll($criteria); //删除PASSWORD相关的信息 $dataFormat = new DataFormat(); $format = $dataFormat->format($userList, null, null); $clientFlash = new ClientFlash(); if ($total > 0) { $clientFlash->pushMobile(0, $format); } else { _echo(3, 数据为空); } } }
public function actionIndex() { $searchForm = new SearchForm(); $gender = null; $residenceFlag = null; $location = null; $latitude = UserRefreshForm::model()->getLatitude(); $longitude = UserRefreshForm::model()->getLongitude(); $criteria = new CDbCriteria(); if (isset($_POST['SearchForm'])) { $gender = $_POST['SearchForm']['gender']; $residenceFlag = $_POST['SearchForm']['residence']; } $nearPersons = MGetNear::getNearPersonsNoOrder(); $criteria->select = ' t.*,tbl_myr_refresh.status as status,(ACOS(SIN((' . $latitude . '* 3.1415) / 180 ) *SIN((tbl_myr_refresh.latitude * 3.1415) / 180 ) +COS((' . $latitude . '* 3.1415) / 180 ) * COS((tbl_myr_refresh.latitude * 3.1415) / 180 ) *COS((' . $longitude . '* 3.1415) / 180 - (tbl_myr_refresh.longitude * 3.1415) / 180 ) ) * 6378.137) as distance'; $criteria->join = 'LEFT JOIN tbl_myr_refresh ON tbl_myr_refresh.userId=t.userId'; $criteria->addInCondition('t.userId', $nearPersons); if ($gender != null) { $criteria->addCondition("gender={$gender}"); } if ($residenceFlag != null) { $currentCity = UserRefreshForm::model()->getCurrentCity(); $residence = Yii::app()->user->residence; switch ($residenceFlag) { case 0: $criteria->addCondition("t.residence='{$currentCity}'"); break; case 1: $criteria->addCondition("t.residence!='{$currentCity}'"); break; default: break; } } $criteria->order = 'distance ASC'; $UserModel = User::model(); $total = $UserModel->count($criteria); $pager = new CPagination($total); $pager->pageSize = 10; $pager->applyLimit($criteria); $userList = $UserModel->findAll($criteria); $dataFormat = new DataFormat(); $format = $dataFormat->format($userList, null, 'distance', 'status'); $data = array('userList' => $format, 'pages' => $pager, 'searchForm' => $searchForm); $clientFlash = new clientFlash(); if ($total > 0) { $clientFlash->pushMobile(0, $format); } else { $clientFlash->pushMobile(3, '数据为空'); } $this->render('index', $data); }
public function actionCommentList($shareId) { $currentTime = time(); $criteria = new CDbCriteria(); $criteria->addCondition('shareId=:shareId'); $criteria->params = array(':shareId' => $shareId); $criteria->order = 't.commentId DESC'; $comment = Comment::model(); $total = $comment->count($criteria); $pager = new CPagination($total); $pager->pageSize = 10; $pager->applyLimit($criteria); $commentList = $comment->findAll($criteria); $dataFormat = new DataFormat(); $format = array(); $clientFlash = new ClientFlash(); $format = $dataFormat->format($commentList); if ($total > 0) { $clientFlash = new ClientFlash(); $clientFlash->pushMobile(0, $format); } else { _echo(3, '数据为空'); } }