當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Yii::apps方法代碼示例

本文整理匯總了PHP中Yii::apps方法的典型用法代碼示例。如果您正苦於以下問題:PHP Yii::apps方法的具體用法?PHP Yii::apps怎麽用?PHP Yii::apps使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Yii的用法示例。


在下文中一共展示了Yii::apps方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: CSVImportGroup


//.........這裏部分代碼省略.........
        foreach ($grouparray as $ga) {
            $gacfieldcontents = convertCSVRowToArray($ga, ',', '"');
            $grouprowdata = array_combine($gafieldorders, $gacfieldcontents);
            // Skip not supported languages
            if (!in_array($grouprowdata['language'], $aLanguagesSupported)) {
                $skippedlanguages[] = $grouprowdata['language'];
                // this is for the message in the end.
                continue;
            }
            // replace the sid
            $iOldSID = $grouprowdata['sid'];
            $grouprowdata['sid'] = $iNewSID;
            // replace the gid  or remove it if needed (it also will calculate the group order if is a new group)
            $oldgid = $grouprowdata['gid'];
            if ($newgid == 0) {
                unset($grouprowdata['gid']);
                // find the maximum group order and use this grouporder+1 to assign it to the new group
                $qmaxgo = "select max(group_order) as maxgo from {{groups}} where sid={$iNewSID}";
                $gres = Yii::app()->db->createCommand($qmaxgo)->query();
                $grow = $gres->read();
                $group_order = $grow['maxgo'] + 1;
            } else {
                $grouprowdata['gid'] = $newgid;
            }
            $grouprowdata["group_order"] = $group_order;
            // Everything set - now insert it
            $grouprowdata = array_map('convertCSVReturnToReturn', $grouprowdata);
            // translate internal links
            $grouprowdata['group_name'] = translateLinks('survey', $iOldSID, $iNewSID, $grouprowdata['group_name']);
            $grouprowdata['description'] = translateLinks('survey', $iOldSID, $iNewSID, $grouprowdata['description']);
            $gres = Yii::app()->db->createCommand()->insert('{{groups}}', $grouprowdata);
            //GET NEW GID  .... if is not done before and we count a group if a new gid is required
            if ($newgid == 0) {
                $newgid = Yii::apps()->db->getCommandBuilder()->getLastInsertID('{{groups}}');
                $countgroups++;
            }
        }
        // GROUPS is DONE
        // Import questions
        if (isset($questionarray) && $questionarray) {
            foreach ($questionarray as $qa) {
                $qacfieldcontents = convertCSVRowToArray($qa, ',', '"');
                $questionrowdata = array_combine($questionfieldnames, $qacfieldcontents);
                $questionrowdata = array_map('convertCSVReturnToReturn', $questionrowdata);
                $questionrowdata["type"] = strtoupper($questionrowdata["type"]);
                // Skip not supported languages
                if (!in_array($questionrowdata['language'], $aLanguagesSupported)) {
                    continue;
                }
                // replace the sid
                $questionrowdata["sid"] = $iNewSID;
                // replace the gid (if the gid is not in the oldgid it means there is a problem with the exported record, so skip it)
                if ($questionrowdata['gid'] == $oldgid) {
                    $questionrowdata['gid'] = $newgid;
                } else {
                    continue;
                }
                // a problem with this question record -> don't consider
                if (isset($aQIDReplacements[$questionrowdata['qid']])) {
                    $questionrowdata['qid'] = $aQIDReplacements[$questionrowdata['qid']];
                } else {
                    $oldqid = $questionrowdata['qid'];
                    unset($questionrowdata['qid']);
                }
                // Save the following values - will need them for proper conversion later                if ((int)$questionrowdata['lid']>0)
                unset($oldlid1);
開發者ID:rawaludin,項目名稱:LimeSurvey,代碼行數:67,代碼來源:import_helper.php


注:本文中的Yii::apps方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。