public function actionDeleteComment() { if (!isset($_POST['id']) || empty($_POST['id'])) { throw new THttpException('评论ID为空!'); } $id = $_POST['id']; if (!is_array($id)) { $id = array($id); } try { $criteria = new CDbCriteria(); $criteria->addInCondition('Id', $id); AppPushListReviews::model()->deleteAll($criteria); echo new ReturnInfo(RET_SUC, '删除评论成功'); } catch (Exception $e) { throw new THttpException('操作失败'); } }
private function _getRandomComment($pushId) { $commentModel = AppPushListReviews::model()->findAll(array('condition' => 'Status=0 and Used=0 and PushId=:PushId and Content !=""', 'params' => array(':PushId' => $pushId), 'order' => new CDbExpression('RAND()'), 'limit' => 1)); if (!$commentModel || !$commentModel[0]) { return false; } return $commentModel[0]; }