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


PHP Question::count方法代码示例

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


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

示例1: run

 public function run()
 {
     $model = new Question();
     //条件
     $criteria = new CDbCriteria();
     $realname = trim(Yii::app()->request->getParam('realname'));
     $question = trim(Yii::app()->request->getParam('question'));
     $question && $criteria->addSearchCondition('question', $question);
     $realname && $criteria->addSearchCondition('realname', $realname);
     $criteria->order = 't.id ASC';
     $count = $model->count($criteria);
     //分页
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $pages->applyLimit($criteria);
     //查询
     $result = $model->findAll($criteria);
     $this->controller->render('index', array('model' => $model, 'datalist' => $result, 'pagebar' => $pages));
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:19,代码来源:IndexAction.php

示例2: actionIndex

 /**
  * 首页
  */
 public function actionIndex()
 {
     $bagecmsQuestionModel = new Question();
     $bagecmsQuestionCriteria = new CDbCriteria();
     $bagecmsQuestionCriteria->condition = 'status_is=:status';
     $bagecmsQuestionCriteria->params = array('status' => 'Y');
     $bagecmsQuestionCriteria->order = 't.id DESC';
     $bagecmsQuestionCount = $bagecmsQuestionModel->count($bagecmsQuestionCriteria);
     $bagecmsQuestionPages = new CPagination($bagecmsQuestionCount);
     $bagecmsQuestionPages->pageSize = 10;
     $bagecmsQuestionPageParams = XUtils::buildCondition($_GET, array());
     $bagecmsQuestionPageParams['#'] = 'list';
     $bagecmsQuestionPages->params = is_array($bagecmsQuestionPageParams) ? $bagecmsQuestionPageParams : array();
     $bagecmsQuestionCriteria->limit = $bagecmsQuestionPages->pageSize;
     $bagecmsQuestionCriteria->offset = $bagecmsQuestionPages->currentPage * $bagecmsQuestionPages->pageSize;
     $bagecmsQuestionList = $bagecmsQuestionModel->findAll($bagecmsQuestionCriteria);
     $this->_seoTitle = '留言咨询 - ' . $this->_conf['site_name'];
     $this->render('index', array('bagecmsQuestionList' => $bagecmsQuestionList, 'pages' => $bagecmsQuestionPages));
 }
开发者ID:tecshuttle,项目名称:51qsk,代码行数:22,代码来源:QuestionController.php

示例3: actionIndex

 /**
  * 首页
  */
 public function actionIndex()
 {
     $model = new Question();
     $criteria = new CDbCriteria();
     $condition = '1';
     $realname = trim($this->_request->getParam('realname'));
     $question = trim($this->_request->getParam('question'));
     $question && ($condition .= ' AND question LIKE \'%' . $question . '%\'');
     $realname && ($condition .= ' AND realname LIKE \'%' . $realname . '%\'');
     $criteria->condition = $condition;
     $criteria->order = 't.id DESC';
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 15;
     $pageParams = $this->buildCondition($_GET, array('site_name'));
     $pages->params = is_array($pageParams) ? $pageParams : array();
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $result = $model->findAll($criteria);
     $this->render('index', array('datalist' => $result, 'pagebar' => $pages));
 }
开发者ID:SallyU,项目名称:yiicms,代码行数:24,代码来源:QuestionController.php

示例4: postGuardar

 public function postGuardar()
 {
     $bandera = false;
     $id = Input::get('idQues');
     $ans = Input::get('res');
     $answers = Answer::all();
     $question = Question::find($id);
     $cantidad = Question::count();
     foreach ($answers as $a) {
         if ($a->id_question == $id) {
             $bandera = true;
             $answer = $a;
             break;
         }
     }
     if (!$bandera) {
         $answer = new Answer();
         $answer->id_question = $id;
         $ids = Auth::id();
         $student = Student::where('id_user', '=', $ids)->get()->first();
         $answer->id_student = $student->id;
         $answer->answer = $ans;
         $answer->result = QuestionsController::verifyAnswer($question, $ans);
         $answer->save();
     } else {
         $answer->result = QuestionsController::verifyAnswer($question, $ans);
         $answer->answer = $ans;
         $answer->save();
     }
     if ($cantidad == $id) {
         return Redirect::to('questions/exam?endTest=yes');
         //"holi ".$id." ".$ans;
     } else {
         if ($cantidad > $id) {
             return Redirect::to('questions/exam?numberQIn=' . ++$id);
         }
     }
 }
开发者ID:ReyesPedro,项目名称:PlataformaPreguntas,代码行数:38,代码来源:SolvingExamsController.php

示例5: array

<?php

include '../../inc/init.inc';
if (isset($tag)) {
    $conditions = array('id in (?)', Questions_Tag::find('all', array('conditions' => array('tag_id' => Tag::find_by_name($tag)->id)))->asQuestion_ID());
}
isset($conditions) ? $args['conditions'] = $conditions : ($args['conditions'] = 'title NOT LIKE ""');
$res->total = isset($args) ? Question::count($args) : Question::count();
$res->currentPage = isset($currentPage) ? $currentPage : 1;
$res->limit = $args['limit'] = isset($limit) ? $limit : 7;
$args['offset'] = ($res->currentPage - 1) * $args['limit'];
$args['order'] = isset($order) ? $order : 'created_at desc';
$res->questions = Question::all($args);
$res->tags = Tag::find('all', array('order' => 'Rand()', 'limit' => 20));
if (!isset($infos)) {
    $infos = array();
}
$res->search_opts = array(0 => array('label' => 'Quelle question vous posez vous ?', 'field' => 'title', 'type' => 'text', 'class' => 'xxlarge'));
$res->useTemplate("Questions - Reponses", $infos);
开发者ID:Osin,项目名称:Intranet,代码行数:19,代码来源:q2a.php

示例6: deletePaperData

 /**
  * 删除Paper 表数据
  * 关联到Question,Question_ans表, 因此不能随意删除
  * 尤其是Question表, 其中的数据必须是在获取到paper_id 之后才能导入
  * @return boolean
  * true 删除成功
  * false 删除失败
  */
 public static function deletePaperData()
 {
     if (Question::count() != 0) {
         throw new Exception("The foreign key is used for table Question!");
     }
     $paper_data = Paper::find();
     try {
         $manager = new TxManager();
         $transaction = $manager->get();
         foreach ($paper_data as $record) {
             if ($record->delete() == false) {
                 $transaction->rollback("Cannot delete Paper data");
             }
         }
         $transaction->commit();
         return true;
     } catch (TxFailed $e) {
         throw new Exception("Failed, reason: " . $e->getMessage());
     }
 }
开发者ID:sunxfancy,项目名称:Questionnaire,代码行数:28,代码来源:DBHandle.php

示例7: Number

	  <div class="content">  
   

   <!--Start : Question Number (Example 2 de 5) -->	 
   
   <div class="row">
          <p class="instructions-title"><span style="background-color: #808285; padding: 3px 3px 3px 3px;">Exam Instructions </span></p>
    </div>
   <!--End : Question Number -->	

    <div class="frame">
                              
<p class="orange-p"> ITIL FOUNDATION (2011)</p>
 <?php 
$exam = Exam::find(1);
echo '<p class="instructions-p ">All ' . Question::count() . ' questions should be attempted</p>';
echo '<p class="instructions-p ">There are no trick questions</p>';
echo '<p class="instructions-p ">You have 75 minutes for this exam</p>';
echo '<p class="instructions-p ">You must get ' . $exam->score . ' points or more to pass</p>';
echo '<p class="instructions-p ">During this exam you are allowed to navigate freely and review items you have already answered</p>';
echo '<p class="instructions-p ">If you have time at the end of the exam you can review your answers or any questions that you flag for review during the exam</p>';
echo '<p class="instructions-p ">Please note that it is strictly forbidden to copy or reproduce the content of this exam without the approval of PEOPLECERT</p>                                  <br>';
?>
                               
		</div>
	    {{ Form::open(array('method' => 'GET', 'route' => array('exam.show', $exam->id))) }}
		      <input type="submit" class="btn-option" value="Next" >
      {{ Form::close() }}
	</div>
	</div>
	          </td>
开发者ID:ReyesPedro,项目名称:PlataformaPreguntas,代码行数:31,代码来源:instructions.blade.php

示例8: prueba2

?>
;
            decrement--;
            window.location.href="exam?numberQDc="+decrement;
          }
        
      }

      function prueba2()
      {
        var increment = <?php 
echo $increment;
?>
;
        var cant = <?php 
echo Question::count();
?>
;
        if(increment == cant)
        {
          alert("Somos iguales");
          increment = 1;
          window.location.href="exam?numberQIn="+increment;
        }else
          {
            alert("Somos diferentes");
            increment++;
            window.location.href="exam?numberQIn="+increment;
          }
      }
        </script>
开发者ID:ReyesPedro,项目名称:PlataformaPreguntas,代码行数:31,代码来源:exam.blade.php

示例9: view

 function view($id, $idQuestion = null)
 {
     if ($idQuestion == null) {
         $adviceDetails = AdviceDetail::where('id_advice', $id)->get();
         $listHistory = Question::whereIn('id', array_diff($adviceDetails->lists('id_question'), Question::$_rootQuestionID))->get();
         if (array_unique($adviceDetails->lists('id_question')) == Question::count()) {
             return View::make('advice.view', ['select' => 'next', 'question' => null, 'listHistory' => $listHistory, 'id' => $id, 'tours' => []]);
         }
         if ($adviceDetails->count() == 0) {
             return Redirect::route('advice.view', ['id' => $id, 'idQuestion' => 'root']);
         } else {
             $adviceDetails = AdviceDetail::where('id_advice', $id)->get();
             //=============
             $questionAnswerLoc = AdviceDetail::where('id_advice', $id)->where('id_question', 1)->first();
             $location = Location::join(Answer::getTableName(), Answer::getTableName() . '.name', '=', Location::getTableName() . '.code')->where(Answer::getTableName() . '.id', $questionAnswerLoc->id_answer)->select(Location::getTableName() . '.*')->first();
             $tours = Tour::where('start_loc', $location->id)->get();
             $listAnsOfNotFactor = $adviceDetails->filter(function ($row) {
                 return !in_array($row->id_question, Question::$_rootQuestionID);
             });
             if ($listAnsOfNotFactor->count() > 0) {
                 $arrAnsPoint = $this->scoreAnswer($listAnsOfNotFactor->lists('id_answer'));
                 $arrAnsPoint = $this->interaction($arrAnsPoint);
                 $idAttrForNext = $this->getAttributeForNext($arrAnsPoint);
                 if ($idAttrForNext) {
                     $listIDQuestionHistory = $adviceDetails->lists('id_question');
                     $strAvoid = implode(',', $listIDQuestionHistory);
                     $questionForNext = DB::select("\n                            SELECT `questions`.*\n                            FROM `questions`\n                            INNER JOIN `question_answer`\n                            ON `questions`.`id` = `question_answer`.`id_question`\n                            INNER JOIN `answers`\n                            ON `question_answer`.`id_answer` = `answers`.`id`\n                            WHERE `answers`.`id_attribute` = {$idAttrForNext}\n                            AND `questions`.`id` NOT IN ({$strAvoid})\n                            GROUP BY `question_answer`.`id_question`\n                            ORDER BY COUNT(DISTINCT `question_answer`.`id_answer`) DESC\n                        ")[0];
                     $question = new Question((array) $questionForNext);
                 }
             } else {
                 $question = Question::find(5);
             }
             return View::make('advice.view', ['select' => 'next', 'question' => $question, 'listHistory' => $listHistory, 'id' => $id, 'tours' => $tours]);
         }
     } else {
         if ($idQuestion == 'root') {
             $questions = Question::whereIn('id', Question::$_rootQuestionID)->get();
             $listHistory = new Collection();
             return View::make('advice.view', ['select' => 'root', 'questions' => $questions, 'listHistory' => $listHistory, 'id' => $id]);
         } else {
             $question = Question::find($idQuestion);
             $adviceDetails = AdviceDetail::where('id_advice', $id)->get();
             $listHistory = Question::whereIn('id', array_diff($adviceDetails->lists('id_question'), array_merge(Question::$_rootQuestionID, [$idQuestion])))->get();
             return View::make('advice.view', ['select' => 'history', 'question' => $question, 'listHistory' => $listHistory, 'id' => $id]);
         }
     }
 }
开发者ID:phucps89,项目名称:Tour,代码行数:47,代码来源:AdviceController.php


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