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


PHP Question::insert方法代码示例

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


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

示例1: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     ini_set('max_execution_time', 0);
     $data = DB::select('select * from question');
     $insert = [];
     foreach ($data as $d) {
         $insert[] = ['id' => $d->id, 'name' => $d->question, 'id_question_type' => $d->answer_type_id];
     }
     Question::insert($insert);
 }
开发者ID:phucps89,项目名称:Tour,代码行数:15,代码来源:QuestionDB.php

示例2: index

 /**
  * Load edit/new question screen depending on $action.
  *
  * @access public
  * @param string $sa subaction
  * @param int $surveyid
  * @param int $gid
  * @param int $qid
  * @return void
  */
 public function index($sa, $surveyid, $gid, $qid = null)
 {
     App()->getClientScript()->registerPackage('qTip2');
     $action = $sa;
     $surveyid = $iSurveyID = sanitize_int($surveyid);
     $gid = sanitize_int($gid);
     if (isset($qid)) {
         $qid = sanitize_int($qid);
     }
     $aViewUrls = array();
     $aData['surveyid'] = $surveyid;
     $aData['gid'] = $gid;
     $aData['qid'] = $qid;
     $aData['display']['menu_bars']['surveysummary'] = 'viewgroup';
     $aData['display']['menu_bars']['gid_action'] = 'addquestion';
     $surveyinfo = Survey::model()->findByPk($iSurveyID)->surveyinfo;
     $aData['title_bar']['title'] = $surveyinfo['surveyls_title'] . "(" . gT("ID") . ":" . $iSurveyID . ")";
     $aData['questiongroupbar']['savebutton']['form'] = 'frmeditgroup';
     $aData['questiongroupbar']['saveandclosebutton']['form'] = 'frmeditgroup';
     $aData['questiongroupbar']['closebutton']['url'] = 'admin/questions/sa/view/surveyid/' . $surveyid . '/gid/' . $gid . '/qid/' . $qid;
     Yii::app()->session['FileManagerContext'] = "create:question:{$surveyid}";
     if (Permission::model()->hasSurveyPermission($surveyid, 'surveycontent', 'read')) {
         $surveyinfo = getSurveyInfo($surveyid);
         Yii::app()->loadHelper('admin/htmleditor');
         Yii::app()->loadHelper('surveytranslator');
         if (isset($_POST['sortorder'])) {
             $postsortorder = sanitize_int($_POST['sortorder']);
         }
         $aData['adding'] = $adding = $action == 'addquestion';
         $aData['copying'] = $copying = $action == 'copyquestion';
         $questlangs = Survey::model()->findByPk($surveyid)->additionalLanguages;
         $baselang = Survey::model()->findByPk($surveyid)->language;
         $questlangs[] = $baselang;
         $questlangs = array_flip($questlangs);
         // Prepare selector Mode TODO: with and without image
         if (!$adding) {
             Yii::app()->session['FileManagerContext'] = "edit:question:{$surveyid}";
             $aData['display']['menu_bars']['qid_action'] = 'editquestion';
             $egresult = Question::model()->findAllByAttributes(array('sid' => $surveyid, 'gid' => $gid, 'qid' => $qid));
             foreach ($egresult as $esrow) {
                 if (!array_key_exists($esrow->language, $questlangs)) {
                     // Language Exists, BUT ITS NOT ON THE SURVEY ANYMORE.
                     $esrow->delete();
                 } else {
                     $questlangs[$esrow->language] = 99;
                 }
                 if ($esrow->language == $baselang) {
                     $esrow = $esrow->attributes;
                     $basesettings = array('question_order' => $esrow['question_order'], 'other' => $esrow['other'], 'mandatory' => $esrow['mandatory'], 'type' => $esrow['type'], 'title' => $esrow['title'], 'preg' => $esrow['preg'], 'question' => $esrow['question'], 'help' => $esrow['help']);
                 }
             }
             if (!$egresult) {
                 $this->getController()->error('Invalid question id');
             }
             while (list($key, $value) = each($questlangs)) {
                 if ($value != 99) {
                     $arQuestion = new Question();
                     $arQuestion->qid = $qid;
                     $arQuestion->sid = $surveyid;
                     $arQuestion->gid = $gid;
                     $arQuestion->type = $basesettings['type'];
                     $arQuestion->title = $basesettings['title'];
                     $arQuestion->question = $basesettings['question'];
                     $arQuestion->preg = $basesettings['preg'];
                     $arQuestion->help = $basesettings['help'];
                     $arQuestion->other = $basesettings['other'];
                     $arQuestion->mandatory = $basesettings['mandatory'];
                     $arQuestion->question_order = $basesettings['question_order'];
                     $arQuestion->language = $key;
                     $arQuestion->insert();
                 }
             }
             $eqresult = Question::model()->with('groups')->together()->findByAttributes(array('sid' => $surveyid, 'gid' => $gid, 'qid' => $qid, 'language' => $baselang));
         } else {
             // This is needed to properly color-code content if it contains replacements
             LimeExpressionManager::StartProcessingPage(false, Yii::app()->baseUrl, true);
             // so can click on syntax highlighting to edit questions
         }
         $qtypelist = getQuestionTypeList('', 'array');
         $qDescToCode = 'qDescToCode = {';
         $qCodeToInfo = 'qCodeToInfo = {';
         foreach ($qtypelist as $qtype => $qdesc) {
             $qDescToCode .= " '{$qdesc['description']}' : '{$qtype}', \n";
             $qCodeToInfo .= " '{$qtype}' : '" . ls_json_encode($qdesc) . "', \n";
         }
         $aData['qTypeOutput'] = "{$qDescToCode} 'null':'null' }; \n {$qCodeToInfo} 'null':'null' };";
         if (!$adding) {
             if (is_object($eqresult->groups)) {
                 $eqrow = array_merge($eqresult->attributes, $eqresult->groups->attributes);
             } else {
//.........这里部分代码省略.........
开发者ID:CSCI-462-01-2016,项目名称:LimeSurvey,代码行数:101,代码来源:questions.php

示例3: addAnswer

function addAnswer()
{
    $question = new Question($_POST);
    if ($question1 = Question::getAnswerByUserId($_SESSION['userId'], $question->question)) {
        $question->id = $question1->id;
        $question->update();
    } else {
        $question->insert();
    }
    header('main.php?action = login');
}
开发者ID:naval777,项目名称:Websites,代码行数:11,代码来源:main.php

示例4: connectToEncryptedMySQL

<?php

require_once "/etc/apache2/capstone-mysql/encrypted-config.php";
require_once "question.php";
$pdo = connectToEncryptedMySQL("/etc/apache2/data-design/jfindley2.ini");
$question = new Question(null, 1, 2, "Huh?", null);
$question->insert($pdo);
$question->setQuestionText("What?");
$question->update($pdo);
$question->delete($pdo);
开发者ID:jfindley2,项目名称:amazon-product,代码行数:10,代码来源:question-shakedown.php


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