public function actionGetCurrentQuestion() { $customer_id = $this->getParam('customer_id'); $flag = $this->getParam('flag'); $current_id = array(); if ($flag == 'today') { $current_id = 2; } else { $current_id = 1; } $question = Converter::convertModelToArray(HiQuestion::model()->findByPk($current_id)); $answers = Converter::convertModelToArray(HiQuestionAnswer::model()->with('customer')->findAllByAttributes(array('customer_id' => $customer_id, 'question_id' => $current_id))); if ($flag == 'today') { $question['has_answered'] = 0; $year = date('Y'); foreach ($answers as $k => $v) { if (strpos('date' . $v['insert_date'], $year)) { $question['has_answered'] = 1; } } } else { $question['has_answered'] = 1; } $question['answers'] = $answers; EchoUtility::echoMsgTF($question, '获取问题', $question); }
public function actionGetHomeData() { $result = array(); $story_c = new CDbCriteria(); $story_c->addCondition('follow_count != 0'); $story_c->order = 'follow_count DESC'; $stories = Converter::convertModelToArray(HiStory::model()->with('customer')->findAll($story_c)); $result['story'] = $stories[0]; $article = Converter::convertModelToArray(HiPushArticle::model()->findByPk(Yii::app()->time_service->getIndex())); $result['article'] = $article; $question = Converter::convertModelToArray(HiQuestion::model()->findByPk(2)); $question['cover_image'] = 'http://77fkpo.com5.z0.glb.clouddn.com/603b2cffffeb7c5c950a4c9517e8ee9e.jpg'; $result['question'] = $question; $book = Converter::convertModelToArray(HiBook::model()->with('customer')->findByPk(1)); $result['book'] = $book; EchoUtility::echoMsgTF(true, '获取首页数据', $result); }