本文整理汇总了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);