当前位置: 首页>>代码示例>>PHP>>正文


PHP Comment::findAll方法代码示例

本文整理汇总了PHP中Comment::findAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Comment::findAll方法的具体用法?PHP Comment::findAll怎么用?PHP Comment::findAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Comment的用法示例。


在下文中一共展示了Comment::findAll方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run()
 {
     $model = new Comment();
     //条件
     $criteria = new CDbCriteria();
     $type = trim(Yii::app()->request->getParam('type'));
     $type && $criteria->addColumnCondition(array('type' => $type));
     $status = trim(Yii::app()->request->getParam('status'));
     $status && $criteria->addColumnCondition(array('status' => $status));
     $title = trim(Yii::app()->request->getParam('content'));
     $title && $criteria->addSearchCondition('content', $title);
     $criteria->order = 't.id DESC';
     $count = $model->count($criteria);
     //分页
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $pages->applyLimit($criteria);
     //查询
     $result = $model->findAll($criteria);
     //全部类型
     $model_types = ModelType::model()->findAll();
     Yii::app()->clientScript->registerCssFile($this->controller->_static_public . "/js/kindeditor/code/prettify.css");
     Yii::app()->clientScript->registerScriptFile($this->controller->_static_public . "/js/kindeditor/code/prettify.js", CClientScript::POS_END);
     $this->controller->render('index', array('model' => $model, 'model_types' => $model_types, 'datalist' => $result, 'pagebar' => $pages));
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:25,代码来源:IndexAction.php

示例2: run

 public function run()
 {
     $controller = $this->getController();
     $this->_setting = $controller->_setting;
     $this->_stylePath = $controller->_stylePath;
     $this->_static_public = $controller->_static_public;
     $controller->_seoTitle = Yii::t('common', 'User Center') . ' - ' . Yii::t('common', 'My Comments') . ' - ' . $this->_setting['site_name'];
     //加载css,js
     Yii::app()->clientScript->registerCssFile($this->_stylePath . "/css/user.css");
     Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/jquery/jquery.js");
     //我的评论
     $uid = Yii::app()->user->id;
     $comment_mod = new Comment();
     $model_type = new ModelType();
     $uid = Yii::app()->user->id;
     $criteria = new CDbCriteria();
     $criteria->condition = 't.user_id=' . $uid;
     $criteria->order = 't.id DESC';
     //分页
     $count = $comment_mod->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 15;
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $datalist = $comment_mod->findAll($criteria);
     foreach ((array) $datalist as $k => $v) {
         $c_mod_class = $controller->_content_models[$v->type];
         $c_mod_name = strtolower($c_mod_class);
         $content_mod = new $c_mod_class();
         $content = $content_mod->findByPk($v->topic_id);
         $datalist[$k]['title'] = $content->title;
         $datalist[$k]['url'] = $controller->createUrl($c_mod_name . '/view', array('id' => $content->id));
     }
     $controller->render('my_comments', array('datalist' => $datalist));
 }
开发者ID:SallyU,项目名称:yiicms,代码行数:35,代码来源:MycommentsAction.php

示例3: actionIndex

 /**
  * 评论管理
  *
  */
 public function actionIndex()
 {
     $this->_model_type = ModelType::model()->findAll();
     $model = new Comment();
     $criteria = new CDbCriteria();
     $condition = '1';
     $status = $this->_request->getParam('status');
     $title = $this->_request->getParam('postTitle');
     $content = $this->_request->getParam('content');
     $type = $this->_request->getParam('type') ? $this->_request->getParam('type') : $this->_type_ids['post'];
     $type && ($condition .= " AND type={$type}");
     $status && ($condition .= " AND t.status='{$status}'");
     $table = array_search($type, $this->_type_ids);
     if ($table == 'goods') {
         $title && ($condition .= " AND {$table}.goods_name LIKE '%{$title} %'");
     } else {
         $title && ($condition .= " AND {$table}.title LIKE '%{$title} %'");
     }
     $content && ($condition .= ' AND t.content LIKE \'%' . $content . '%\'');
     $criteria->condition = $condition;
     $criteria->order = 't.id DESC';
     $criteria->with = array($table);
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 13;
     $pageParams = $this->buildCondition($_GET, array('postTitle', 'status', 'content', 'type'));
     $pages->params = is_array($pageParams) ? $pageParams : array();
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $result = $model->findAll($criteria);
     Yii::app()->clientScript->registerCssFile($this->_static_public . "/js/kindeditor/code/prettify.css");
     Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/kindeditor/code/prettify.js", CClientScript::POS_END);
     $this->render('index', array('datalist' => $result, 'pagebar' => $pages, 'table' => $table));
 }
开发者ID:redtreelchao,项目名称:wander-moon,代码行数:38,代码来源:CommentController.php

示例4: run

 public function run()
 {
     $controller = $this->getController();
     $controller->_seoTitle = Yii::t('common', 'User Center') . ' - ' . Yii::t('common', 'My Comments') . ' - ' . $controller->_setting['site_name'];
     //我的评论
     $uid = Yii::app()->user->id;
     $comment_mod = new Comment();
     $criteria = new CDbCriteria();
     $criteria->addColumnCondition(array('t.user_id' => $uid));
     $criteria->order = 't.id DESC';
     //分页
     $count = $comment_mod->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 15;
     $pages->applyLimit($criteria);
     $datalist = $comment_mod->findAll($criteria);
     foreach ((array) $datalist as $k => $v) {
         $c_mod_class = $controller->_content_models[$v->type];
         $c_mod_name = strtolower($c_mod_class);
         $content_mod = new $c_mod_class();
         $content = $content_mod->findByPk($v->content_id);
         $datalist[$k]['title'] = $content->title;
         $datalist[$k]['url'] = $controller->createUrl($c_mod_name . '/view', array('id' => $content->id));
     }
     $controller->render('my_comments', array('datalist' => $datalist, 'pages' => $pages));
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:26,代码来源:MycommentsAction.php

示例5: get

 /**
  * Get a list of comments
  *
  * @param Request $request
  * @param string $params
  * @return void
  */
 protected static function get($request, $params)
 {
     try {
         $comments = Comment::query($request->get('queryParams'), $request->include);
     } catch (OutOfBoundsException $e) {
         $comments = Comment::findAll($request->include);
     }
     static::response($comments, 200);
 }
开发者ID:anehx,项目名称:blog,代码行数:16,代码来源:CommentListController.class.php

示例6: moderation

 function moderation($page = 0)
 {
     $this->display('comment/views/moderation', array('comments' => Comment::findAll(), 'page' => $page));
 }
开发者ID:julpi,项目名称:FreshCMS,代码行数:4,代码来源:CommentController.php

示例7: run

 public function run()
 {
     $this->controller->layout = false;
     $view_url = Yii::app()->request->getParam('view_url');
     $content_id = Yii::app()->request->getParam('content_id');
     $topic_type = Yii::app()->request->getParam('topic_type');
     $cur_url = Yii::app()->request->hostinfo . Yii::app()->request->getUrl();
     $post = false;
     //评论类型
     switch ($topic_type) {
         case 'post':
             $post = Post::model()->findByPk($content_id);
             break;
         case 'image':
             $post = Image::model()->findByPk($content_id);
             break;
         case 'soft':
             $post = Soft::model()->findByPk($content_id);
             break;
         case 'video':
             $post = Video::model()->findByPk($content_id);
             break;
     }
     if (!$post) {
         throw new CHttpException(404, Yii::t('admin', 'Loading Error'));
     }
     //评论内容
     $model = new Comment('create');
     $criteria = new CDbCriteria();
     $criteria->with = array('user');
     $criteria->addColumnCondition(array('content_id' => $content_id));
     $criteria->addColumnCondition(array('t.status' => Comment::STATUS_SHOW));
     $criteria->addColumnCondition(array('type' => $this->controller->_type_ids[$topic_type]));
     $criteria->addCondition('u.uid > 0');
     $criteria->order = 't.id DESC';
     $criteria->select = 't.id, user_id, content_id, content, t.create_time ';
     //分页
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $comments = $model->findAll($criteria);
     //回复
     if ($comments) {
         foreach ($comments as $c) {
             $replies[$c->id] = Reply::model()->with('user')->findAll(array('condition' => 'cid = ' . $c->id . ' AND t.status = "' . Reply::STATUS_SHOW . '" AND u.uid > 0', 'order' => 'id'));
         }
     } else {
         $comments = array();
         $replies = array();
     }
     if (Yii::app()->request->isPostRequest) {
         $uid = Yii::app()->user->id;
         if (!$uid) {
             $this->message('script', Yii::t('common', 'You Need Login'));
         }
         $model->attributes = $_POST['Comment'];
         $model->content_id = $content_id;
         $model->type = $this->controller->_type_ids[$topic_type];
         $model->user_id = $uid;
         $model->status = 'N';
         $model->client_ip = Yii::app()->request->userHostAddress;
         $model->create_time = time();
         $ret_url = $_POST['ret_url'];
         if ($model->save()) {
             $this->controller->message('script', Yii::t('common', 'Submit Success, Waiting Pass'), $ret_url);
         }
     }
     $data = array('model' => $model, 'view_url' => $view_url, 'cur_url' => $cur_url, 'comments' => $comments, 'pagebar' => $pages, 'replies' => $replies);
     $this->controller->render('create', $data);
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:72,代码来源:CreateAction.php

示例8: index

 function index()
 {
     $this->display('comment/views/index', array('comments' => Comment::findAll()));
 }
开发者ID:albertobraschi,项目名称:toad,代码行数:4,代码来源:CommentController.php

示例9: actionCreate

 /**
  * 提交评论
  *
  * @return [type] [description]
  */
 public function actionCreate()
 {
     $this->layout = false;
     $view_url = $this->_request->getParam('view_url');
     $topic_id = $this->_request->getParam('topic_id');
     $topic_type = $this->_request->getParam('topic_type');
     $cur_url = $this->_request->hostinfo . $this->_request->getUrl();
     $post = false;
     //评论类型
     switch ($topic_type) {
         case 'post':
             $post = Post::model()->findByPk($topic_id);
             break;
         case 'image':
             $post = Image::model()->findByPk($topic_id);
             break;
         case 'soft':
             $post = Soft::model()->findByPk($topic_id);
             break;
         case 'video':
             $post = Video::model()->findByPk($topic_id);
             break;
     }
     if (!$post) {
         throw new CHttpException(404, Yii::t('admin', 'Submit Error'));
         break;
     }
     //评论内容
     $model = new Comment('create');
     $criteria = new CDbCriteria();
     $condition = "topic_id={$topic_id} AND status='Y' AND type={$this->_type_ids[$topic_type]}";
     $criteria->condition = $condition;
     $criteria->order = 'id DESC';
     $criteria->select = "id, user_id, topic_id, content, create_time ";
     //分页
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $comments = $model->findAll($criteria);
     //回复
     if ($comments) {
         foreach ((array) $comments as $c) {
             $replies[$c->id] = Reply::model()->findAll('cid=:cid AND status=:status ORDER BY id', array(':cid' => $c->id, ':status' => 'Y'));
         }
     }
     //加载css,js
     Yii::app()->clientScript->registerCssFile($this->_stylePath . "/css/comment.css");
     Yii::app()->clientScript->registerCssFile($this->_static_public . "/js/kindeditor/code/prettify.css");
     Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/jquery/jquery.js");
     Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/kindeditor/code/prettify.js", CClientScript::POS_END);
     if ($this->_request->isPostRequest) {
         $uid = Yii::app()->user->id;
         if (!$uid) {
             $this->message('script', Yii::t('common', 'You Need Login'));
         }
         $model->attributes = $_POST['Comment'];
         $model->topic_id = $topic_id;
         $model->type = $this->_type_ids[$topic_type];
         $model->user_id = $uid;
         $model->status = 'N';
         $model->client_ip = $this->_request->userHostAddress;
         $model->create_time = time();
         $ret_url = $_POST['ret_url'];
         if ($model->save()) {
             $this->message('script', Yii::t('common', 'Submit Success, Waiting Pass'), $ret_url);
             //$this->redirect($ret_url);
         }
     }
     $data = array('model' => $model, 'view_url' => $view_url, 'cur_url' => $cur_url, 'comments' => $comments, 'pagebar' => $pages, 'replies' => $replies);
     $this->render('create', $data);
 }
开发者ID:SallyU,项目名称:yiicms,代码行数:78,代码来源:CommentController.php

示例10: array

<?php

require_once "../models/db.php";
require_once "../models/Comment.php";
require_once "../models/User.php";
$result = array();
$names = array();
$comments;
$user = new User();
if ($_GET["time"] == "") {
    $comments = Comment::findAll($dbh);
} else {
    $comments = Comment::findNewComments($_GET["time"], $dbh);
}
foreach ($comments as $comment) {
    $user->find($comment->author_id, $dbh);
    array_push($names, $user->name);
}
array_push($result, $comments);
array_push($result, $names);
header("Content-type: text/json");
echo json_encode($result);
开发者ID:elifah93,项目名称:Internet-Programming,代码行数:22,代码来源:ListComments.php


注:本文中的Comment::findAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。