public function actionGetArticleById() { $article_id = $this->getParam('article_id'); $customer_id = $this->getParam('customer_id'); $article = Converter::convertModelToArray(HiPushArticle::model()->with('sections')->findByPk($article_id)); $c = new CDbCriteria(); $c->addCondition("article_ids LIKE '%\"" . (int) $article_id . "\"%' and customer_id = " . $customer_id); $article['is_favourite'] = HiPushArticleFavourite::model()->count($c); EchoUtility::echoMsgTF(1, '获取文章', $article); }
public function actionGetFavouritePushArticle() { $customer_id = $this->getParam("customer_id"); $ids = HiPushArticleFavourite::model()->findByAttributes(array('customer_id' => $customer_id)); $result = array(); if (!empty($ids)) { $c = new CDbCriteria(); $c->addInCondition('article_id', json_decode($ids['article_ids'])); $result = Converter::convertModelToArray(HiPushArticle::model()->findAll($c)); } EchoUtility::echoMsgTF(true, '获取收藏的故事', $result); }