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


PHP Topic::model方法代码示例

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


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

示例1: run

 public function run()
 {
     $criteria = new CdbCriteria();
     $criteria->limit = $this->data('limit');
     $criteria->offset = $this->data('offset');
     $criteria->condition = "post_status='publish' AND (post_modified <= '" . date('Y-m-d H:i:s') . "' AND post_modified >= '" . $this->data('time') . "')";
     $criteria->order = 'post_hits DESC';
     if ($this->data('autoByTerm')) {
         if (isset($_GET['id'])) {
             $category = Category::model()->findByPK((int) $_GET['id']);
             $label = Label::model()->findByPK((int) $_GET['id']);
             $topic = Topic::model()->findByPK((int) $_GET['id']);
             $tag = Tag::model()->findByPK((int) $_GET['id']);
             if ($category != null) {
                 $criteria = $this->getCriteriaTerm('categories', $criteria);
             } elseif ($label != null) {
                 $criteria = $this->getCriteriaTerm('labels', $criteria);
             } elseif ($topic != null) {
                 $criteria = $this->getCriteriaTerm('topics', $criteria);
             } elseif ($tag != null) {
                 $criteria = $this->getCriteriaTerm('tags', $criteria);
             }
         }
     }
     $model = Post::model()->findAll($criteria);
     if ($model != null) {
         $this->layout($model);
     }
 }
开发者ID:beckblurry,项目名称:Yii1-Base-Core-V.Alpha.1,代码行数:29,代码来源:widget_terpopuler.php

示例2: actionList

 public function actionList()
 {
     $criteria = new CDbCriteria();
     $criteria->order = 'id asc';
     $topics = Topic::model()->findAll($criteria);
     $this->render('list', array('topics' => $topics));
 }
开发者ID:jackycgq,项目名称:24beta,代码行数:7,代码来源:TopicController.php

示例3: loadModel

 private function loadModel($id, $slug)
 {
     $models = Topic::model()->findByAttributes(array('term_id' => (int) $id, 'slug' => $slug));
     if ($models === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $models;
 }
开发者ID:beckblurry,项目名称:Yii1-Base-Core-V.Alpha.1,代码行数:8,代码来源:TopicController.php

示例4: actionList

 public function actionList()
 {
     $this->channel = 'topic';
     $criteria = new CDbCriteria();
     $criteria->order = 'orderid desc, post_nums desc, id asc';
     $topics = Topic::model()->findAll($criteria);
     $this->setSiteTitle(t('all_topic_list'));
     $this->setPageKeyWords(null);
     $this->setPageDescription(t('all_topics_description'));
     cs()->registerMetaTag('all', 'robots');
     $this->render('list', array('topics' => $topics));
 }
开发者ID:rainsongsky,项目名称:24beta,代码行数:12,代码来源:TopicController.php

示例5: loadTag

 public function loadTag($data = '', $operation = 'OR')
 {
     $criteria = new CdbCriteria();
     $cond = '';
     $criteria = new CDbCriteria();
     if (!empty($data)) {
         foreach ($data as $key => $val) {
             $cond .= " term_id='{$val}' ";
             if (end($data) !== $val) {
                 $cond .= $operation;
             }
         }
     }
     $criteria->condition = $cond;
     $criteria->order = "name DESC";
     $model = Topic::model()->findAll($criteria);
     return $model;
 }
开发者ID:beckblurry,项目名称:Yii1-Base-Core-V.Alpha.1,代码行数:18,代码来源:widget_topics.php

示例6: actionCreate

 /**
  * Creates a new posts.
  * If creation is successful, the browser will be redirected to the 'show' page.
  */
 public function actionCreate()
 {
     if (isset($_POST['Post'])) {
         $user = User::model()->find('username = :username', array('username' => Yii::app()->user->name));
         $session = Yii::app()->session;
         $topic = Topic::model()->findByPk($session['topic_id']);
         $forum = Forum::model()->findByPk($session['forum_id']);
         /*$transaction = Post::model()->dbConnection->beginTransaction();
         		try {
         		*/
         $now = date('Y-m-d H:i:s');
         $post = new Post();
         $post->user_id = $user->id;
         $post->topic_id = $session['topic_id'];
         $post->forum_id = $session['forum_id'];
         $post->body = $_POST['Post']['body'];
         // TODO: fix me
         $post->body_html = $post->body;
         $post->created_at = $now;
         $post->updated_at = $now;
         if (!$post->save()) {
             var_dump('<pre>', $post->getErrors());
         }
         if (!$user->save()) {
             var_dump('<pre>', $user->getErrors());
         }
         $topic->updated_at = $now;
         /*$topic->replied_at = $now;
         		$topic->replied_by = $user->id;
         		$topic->last_post_id = $post->id;*/
         if (!$topic->save()) {
             var_dump('<pre>', $topic->getErrors());
         }
         /*$transaction->commit();
         
         			} catch(Exception $e) {
         				$transaction->rollBack();
         				throw new CHttpException(500, 'Failed to save post');
         			}*/
         $url = $this->createUrl('topic/view', array('id' => $session['topic_id'], '#' => "post-{$post->id}"));
         $this->redirect($url);
     }
 }
开发者ID:knut,项目名称:hamster,代码行数:47,代码来源:PostController.php

示例7: actionIndex

 /**
  * 显示主页
  * @param String $order
  */
 public function actionIndex($order = "new")
 {
     //根据不同的order 选择不同的sql语句
     switch ($order) {
         case 'new':
             $sql = "select `{{question}}`.`id` as `question_id`,`{{question}}`.`question_content`,`{{question}}`.`add_time`,`{{question}}`.`answer_count`,`{{question}}`.`view_count`,`{{question}}`.`lock`,`{{question}}`.`best_answer`,`{{users}}`.`avatar_file`,`{{users}}`.`uid`\n\t\t\t\tfrom `{{question}}`\n\t\t\t\tleft join `{{users}}` on (`{{question}}`.`published_uid`=`{{users}}`.`uid`) order by `{{question}}`.`add_time` desc\n\t\t\t\t";
             break;
             //热门查看人数排序
         //热门查看人数排序
         case 'hot':
             $sql = "select `{{question}}`.`id` as `question_id`,`{{question}}`.`question_content`,`{{question}}`.`add_time`,`{{question}}`.`answer_count`,`{{question}}`.`view_count`,`{{question}}`.`lock`\n\t\t\t\t,`{{users}}`.`avatar_file`,`{{users}}`.`uid`\n\t\t\t\tfrom `{{question}}`\n\t\t\t\tleft join `{{users}}` on (`{{question}}`.`published_uid`=`{{users}}`.`uid`) order by `{{question}}`.`view_count` desc\n\t\t\t\t";
             break;
             //未回复数排序
         //未回复数排序
         case 'unresponsive':
             $sql = "select `{{question}}`.`id` as `question_id`,`{{question}}`.`question_content`,`{{question}}`.`add_time`,`{{question}}`.`answer_count`,`{{question}}`.`view_count`,`{{question}}`.`lock`\n\t\t\t\t,`{{users}}`.`avatar_file`,`{{users}}`.`uid`\n\t\t\t\tfrom `{{question}}`\n\t\t\t\tleft join `{{users}}` on (`{{question}}`.`published_uid`=`{{users}}`.`uid`) where `{{question}}`.`answer_count` = 0\n\t\t\t\t";
             break;
             //默认根据时间排序
         //默认根据时间排序
         default:
             $sql = "select `{{question}}`.`id` as `question_id`,`{{question}}`.`question_content`,`{{question}}`.`add_time`,`{{question}}`.`answer_count`,`{{question}}`.`view_count`,`{{question}}`.`lock`\n\t\t\t\t,`{{users}}`.`avatar_file`,`{{users}}`.`uid`\n\t\t\t\tfrom `{{question}}`\n\t\t\t\tleft join `{{users}}` on (`{{question}}`.`published_uid`=`{{users}}`.`uid`) order by `{{question}}`.`add_time` desc\n\t\t\t\t";
             break;
     }
     $connection = Yii::app()->db;
     $criteria = new CDbCriteria();
     $models = $connection->createCommand($sql)->queryAll();
     $count = count($models);
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $pages->applylimit($criteria);
     $models = $connection->createCommand($sql . " LIMIT :offset,:limit");
     $models->bindValue(':offset', $pages->currentPage * $pages->pageSize);
     $models->bindValue(':limit', $pages->pageSize);
     $models = $models->queryAll();
     //获取话题
     $topic_models = Topic::model()->findAll(array('select' => 'id,topic_title', 'order' => 'discuss_count desc', 'limit' => '25'));
     $this->pageTitle = "首页";
     $this->render('index', array('models' => $models, 'pages' => $pages, 'topic_models' => $topic_models));
 }
开发者ID:jvlstudio,项目名称:ask,代码行数:43,代码来源:SiteController.php

示例8: actionDelete

 /**
  * 删除信息
  * 多表删除  事物处理
  * 删除 question 中信息
  * 删除 answer 表中信息
  * 删除 question 
  * 更新topic中次数
  */
 public function actionDelete($id)
 {
     $transaction = Yii::app()->db->beginTransaction();
     try {
         //删除question 表信息
         if (!Question::model()->deleteByPk($id)) {
             throw new Exception("删除question表失败");
         }
         //删除 topic_question 表 首先把 topic  id 查找出来
         //获取topic id
         $topic_ids = TopicQuestion::model()->findAll(array('select' => 'topic_id', 'condition' => 'question_id=:question_id', 'params' => array(':question_id' => $id)));
         //更新 topic次数
         foreach ($topic_ids as $model) {
             //更新topic 次数
             if (!Topic::model()->updateByPk($model->topic_id, array('discuss_count' => new CDbExpression('discuss_count-1')))) {
                 throw new ErrorException('更新失败');
             }
         }
         //删除topic_question 表中信息
         if (false === TopicQuestion::model()->deleteAll('question_id=:question_id', array('question_id' => $id))) {
             throw new ErrorException('删除topic_question中信息失败');
         }
         //删除question_comment 中信息
         if (false === QuestionComments::model()->deleteAll('question_id=:question_id', array('question_id' => $id))) {
             throw new ErrorException('删除question_comment中信息失败');
         }
         //获取answer_comment 中id
         $answer_comment_models = Answer::model()->findAll(array('select' => 'id', 'condition' => 'question_id=:question_id', 'params' => array(':question_id' => $id)));
         //删除answer_comment 中信息
         foreach ($answer_comment_models as $answer_comment_model) {
             if (false === AnswerComments::model()->deleteAll('answer_id=:answer_id', array(':answer_id' => $answer_comment_model->id))) {
                 throw new ErrorException('删除answer_comment中信息失败');
             }
         }
         //删除answer 表中信息
         if (false === Answer::model()->deleteAll('question_id=:question_id', array('question_id' => $id))) {
             throw new ErrorException('删除answer中信息失败');
         }
         //删除question_focus 中信息
         if (false === QuestionFocus::model()->deleteAll('question_id=:question_id', array('question_id' => $id))) {
             throw new ErrorException('删除question_focus 中信息失败');
         }
         $transaction->commit();
         $this->success('删除成功');
     } catch (Exception $e) {
         $transaction->rollBack();
         exit($e->getMessage());
         $this->error($e->getMessage());
     }
 }
开发者ID:jvlstudio,项目名称:ask,代码行数:58,代码来源:QuestionController.php

示例9: loadModel

 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Topic the loaded model
  * @throws CHttpException
  */
 public function loadModel($name)
 {
     //$model=Topic::model()->findByPk($id);
     $model = Topic::model()->findByAttributes(array('name' => $name));
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
开发者ID:stan5621,项目名称:eduwind,代码行数:16,代码来源:TopicController.php

示例10: array

if ($lenght != 0) {
    echo $form->select2Row($userModel, 'topic_ids', array('asDropDownList' => false, 'options' => array('multiple' => true, 'maximumSelectionSize' => $lenght, 'placeholder' => '请输入删除话题', 'width' => '70%', 'tokenSeparators' => array(',', ' '), 'ajax' => array('url' => $this->createUrl('searchtopic'), 'dataType' => 'json', 'data' => 'js: function (term,page) {  return {  name: term , };}', 'results' => 'js: function (data,page) {return {results: data};}'))));
} else {
    echo $form->hiddenField($userModel, 'topic_ids');
}
if ($userModel->topic_ids != "") {
    ?>
        <div class="control-group ">
            <label class="control-label" for="s2id_autogen1">已添加的擅长的话题</label>
            <div class="controls">
                <?php 
    $topicArrays = explode(",", trim($userModel->topic_ids, ","));
    ?>
                <?php 
    foreach ($topicArrays as $topicArray) {
        $topicModel = Topic::model()->findByPk($topicArray);
        ?>
                    <span class="label"><?php 
        echo $topicModel->name;
        ?>
<a href="javascript:;" title="删除" data-type="removetopic" onclick="removeTopic(<?php 
        echo $topicModel->id;
        ?>
)" data-value="<?php 
        echo $topicModel->id;
        ?>
" style="color:#fff;">×</a></span>
                <?php 
    }
    ?>
            </div>
开发者ID:ruzuojun,项目名称:shiqu,代码行数:31,代码来源:_personInfo.php

示例11: array

<style>
    #toModal .control-label{width: 70px;}
    #groupModal .controls{margin-left: 80px;}
</style>
<?php 
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'topic-form', 'type' => 'horizontal', 'action' => $action, 'htmlOptions' => array('enctype' => 'multipart/form-data')));
$score = Sys::model()->getvaluesByType("topic_score");
if (Sys::model()->getvaluesByType("topic_type") == "0") {
    $hint = "新建话题奖励你" . $score . "个财富值";
} else {
    $hint = "新建话题会花掉你" . $score . "个财富值";
}
echo $form->textFieldRow($topicModel, 'name', array("hint" => $hint));
echo $form->textAreaRow($topicModel, 'desc');
echo $form->dropDownListRow($topicModel, 'parent_id', Topic::model()->listTopics(0, '', '', '默认话题'), array('encode' => false));
echo $form->fileFieldRow($topicModel, 'logo', array('hint' => '上传图片格式为:gif、jpg、jpeg、png'));
$this->endwidget();
开发者ID:ruzuojun,项目名称:shiqu,代码行数:17,代码来源:_topicform.php

示例12: actionViewRecommend

 public function actionViewRecommend()
 {
     header('Content-type: application/json');
     if (!IjoyPlusServiceUtils::validateAPPKey()) {
         IjoyPlusServiceUtils::exportServiceError(Constants::APP_KEY_INVALID);
         return;
     }
     if (IjoyPlusServiceUtils::validateUserID()) {
         IjoyPlusServiceUtils::exportServiceError(Constants::USER_ID_INVALID);
         return;
     }
     $prod_id = Yii::app()->request->getParam("prod_id");
     if (!isset($prod_id) || is_null($prod_id)) {
         IjoyPlusServiceUtils::exportServiceError(Constants::PARAM_IS_INVALID);
         return;
     }
     $program = Program::model()->findByPk($prod_id);
     if ($program === null) {
         IjoyPlusServiceUtils::exportServiceError(Constants::OBJECT_NOT_FOUND);
         return;
     }
     $userid = Yii::app()->request->getParam("user_id");
     if (!isset($userid) || is_null($userid)) {
         $userid = Yii::app()->user->id;
     }
     $prod = ProgramUtil::exportProgramEntity($program);
     $reCom = Dynamic::model()->getDynamicByProd($userid, $prod_id, Constants::DYNAMIC_TYPE_RECOMMEND);
     if (isset($reCom) && !is_null($reCom)) {
         $prod['reason'] = $reCom->content_desc;
     }
     $comments = Comment::model()->getCommentsByProgram($prod_id, 10, 0);
     if (isset($comments) && is_array($comments)) {
         $commentTemps = array();
         foreach ($comments as $comment) {
             $commentTemps[] = IjoyPlusServiceUtils::transferComments($comment);
         }
         $prod['comments'] = $commentTemps;
     } else {
         $prod['comments'] = array();
     }
     $dynamic = Dynamic::model()->friendDynamicForProgram(Yii::app()->user->id, $prod_id, 10, 0);
     if (isset($dynamic) && is_array($dynamic)) {
         $prod['dynamics'] = $this->transferDynamics($dynamic);
     } else {
         $prod['dynamics'] = array();
     }
     $topics = Topic::model()->getRelatedTops($prod_id);
     if (isset($topics) && is_array($topics)) {
         $prod['topics'] = $topics;
     } else {
         $prod['topics'] = array();
     }
     IjoyPlusServiceUtils::exportEntity($prod);
 }
开发者ID:andyongithub,项目名称:joyplus-cms,代码行数:54,代码来源:ProgramController.php

示例13: array

echo $form->textField($model, 'img_id', array('size' => 10, 'maxlength' => 10));
?>
	</div>

	<div class="row">
		<?php 
echo $form->label($model, 'usr_id');
echo $form->dropDownList($model, 'usr_id', CHtml::listData(User::model()->findAll(), 'usr_id', 'name'));
?>
    
	</div>

	<div class="row">
		<?php 
echo $form->label($model, 'topic_id');
echo $form->dropDownList($model, 'topic_id', CHtml::listData(Topic::model()->findAll(), 'topic_id', 'topic'));
?>
    
	</div>

	<div class="row">
		<?php 
echo $form->label($model, 'cmt');
?>
		<?php 
echo $form->textField($model, 'cmt', array('size' => 60, 'maxlength' => 255));
?>
	</div>

	<div class="row">
		<?php 
开发者ID:sr71k,项目名称:pet,代码行数:31,代码来源:_search.php

示例14: CDbCriteria

        ?>
个问题)</span></div>
                        <?php 
    }
} else {
    echo "<div class='alert alert-info'>暂无最新话题</div>";
}
?>
            </fieldset>
            <fieldset>
                <legend style="margin-bottom: 10px;">最新话题</legend> 
                <?php 
$criteria = new CDbCriteria();
$criteria->order = "create_time  desc";
$criteria->limit = 10;
$newTopicModel = Topic::model()->findAll($criteria);
$count = array();
if (!empty($newTopicModel)) {
    foreach ($newTopicModel as $newTopic) {
        ?>
                        <div class="clearfix" style="padding:4px 0;"><a class="topic-label" style="margin-right:4px;" data-id="<?php 
        echo $newTopic->id;
        ?>
" href="javascript:;" style="margin-right:4px;"><span class="badge"><?php 
        echo $newTopic->name;
        ?>
</span></a><span style="color:#ccc;margin-left:0;">(共<?php 
        echo Question::model()->count("topic_ids like '%," . $newTopic->id . ",%'");
        ?>
个问题)</span></div>
                                <?php 
开发者ID:ruzuojun,项目名称:shiqu,代码行数:31,代码来源:allquestion.php

示例15: loadTopic

 /**
  * Loads the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  */
 protected function loadTopic()
 {
     if (isset($_GET['id'])) {
         $topic = Topic::model()->with('posts')->findbyPk($_GET['id']);
     }
     //die(var_dump($topic));
     if (isset($topic)) {
         return $topic;
     } else {
         throw new CHttpException(500, 'The requested topic does not exist.');
     }
 }
开发者ID:knut,项目名称:hamster,代码行数:16,代码来源:TopicController.php


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