本文整理汇总了PHP中FileModel::fetchAll方法的典型用法代码示例。如果您正苦于以下问题:PHP FileModel::fetchAll方法的具体用法?PHP FileModel::fetchAll怎么用?PHP FileModel::fetchAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileModel
的用法示例。
在下文中一共展示了FileModel::fetchAll方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDeleteByInstance
public function testDeleteByInstance()
{
$properties = array('filename' => 'sample.pdf', 'mime' => 'application/pdf');
$filesNoId = new FileModel(new NoInstanceFoo());
$filesNoId->storeFilename(TEST_PATH . '/fixtures/sample.pdf', $properties);
$filesId = new FileModel(new InstanceFoo());
$filesId->storeFilename(TEST_PATH . '/fixtures/sample.pdf', $properties);
FileModel::deleteByInstance(1);
$this->assertEquals(count($filesId->fetchAll()), 0);
$this->assertEquals(count($filesNoId->fetchAll()), 1);
}
示例2: toXML
/**
* Exports an Instance XML Document
*
* @param integer If true, exports the entire questionnaire definition (question text, etc).
* If false, only exports guid and response data.
* @param array PageHeader strings to export. If empty, export entire instance.
* @return string XML Document
*/
public function toXML($complete = 0, $pageHeaders = array())
{
$instanceID = $this->instanceRow->instanceID;
QFrame_Db_Table::resetAll();
$this->attachmentQuestions = FileModel::fetchObjectIdsByInstance($this->instanceRow->instanceID);
$instance = new InstanceModel(array('instanceID' => $instanceID, 'depth' => 'response'));
$xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$xml .= '<csi:questionnaire';
$xml .= ' xmlns:csi="http://www.csinitiative.com/ns/csi-qframe"';
$xml .= ' questionnaireName="' . self::_xmlentities($instance->questionnaireName) . '" questionnaireVersion="' . self::_xmlentities($instance->questionnaireVersion) . '" revision="' . self::_xmlentities($instance->revision) . '" targetQFrameVersion="' . QFRAME_VERSION . '" instanceName="' . self::_xmlentities($instance->instanceName) . '">' . "\n";
$xml .= " <csi:pages>\n";
while ($page = $instance->nextPage()) {
if (count($pageHeaders) > 0 && array_search($page->pageHeader, $pageHeaders) === FALSE) {
continue;
}
$xml .= " <csi:page>\n";
if ($complete) {
$xml .= " <csi:pageHeader>" . self::_xmlentities($page->pageHeader) . "</csi:pageHeader>\n";
}
$xml .= " <csi:pageGUID>" . self::_xmlentities($page->pageGUID) . "</csi:pageGUID>\n";
$xml .= " <csi:seqNumber>" . self::_xmlentities($page->seqNumber) . "</csi:seqNumber>\n";
if ($complete) {
$xml .= " <csi:description>" . self::_xmlentities($page->description) . "</csi:description>\n";
$xml .= " <csi:headerText>" . self::_xmlentities($page->headerText) . "</csi:headerText>\n";
$xml .= " <csi:footerText>" . self::_xmlentities($page->footerText) . "</csi:footerText>\n";
$xml .= " <csi:cloneable>" . self::_xmlentities($page->cloneable) . "</csi:cloneable>\n";
$xml .= " <csi:defaultPageHidden>" . self::_xmlentities($page->defaultPageHidden) . "</csi:defaultPageHidden>\n";
}
$xml .= " <csi:sections>\n";
while ($section = $page->nextSection()) {
$xml .= " <csi:section>\n";
if ($complete) {
$xml .= ' <csi:sectionHeader>' . self::_xmlentities($section->sectionHeader) . "</csi:sectionHeader>\n";
}
$xml .= ' <csi:sectionGUID>' . self::_xmlentities($section->sectionGUID) . "</csi:sectionGUID>\n";
$xml .= ' <csi:seqNumber>' . self::_xmlentities($section->seqNumber) . "</csi:seqNumber>\n";
if ($complete) {
$xml .= ' <csi:description>' . self::_xmlentities($section->description) . "</csi:description>\n";
$xml .= ' <csi:cloneable>' . self::_xmlentities($section->cloneable) . "</csi:cloneable>\n";
$xml .= ' <csi:defaultSectionHidden>' . self::_xmlentities($section->defaultSectionHidden) . "</csi:defaultSectionHidden>\n";
$references = $section->references;
if (count($references) > 0) {
$xml .= " <csi:sectionReferences>";
foreach ($references as $reference) {
$xml .= " <csi:reference>";
$xml .= ' <csi:shortName>' . self::_xmlentities($reference['shortName']) . "</csi:shortName>\n";
$xml .= ' <csi:referenceName>' . self::_xmlentities($reference['referenceName']) . "</csi:referenceName>\n";
$xml .= ' <csi:item>' . self::_xmlentities($reference['item']) . "</csi:item>\n";
$xml .= ' <csi:referenceURL>' . self::_xmlentities($reference['referenceURL']) . "</csi:referenceURL>\n";
$xml .= ' <csi:referenceText>' . self::_xmlentities($reference['referenceText']) . "</csi:referenceText>\n";
$xml .= "</csi:reference>\n";
}
$xml .= "</csi:sectionReferences>\n";
}
}
$xml .= " <csi:questions>\n";
while ($question = $section->nextQuestion()) {
$padding = '';
if (count($question->children)) {
$xml .= " <csi:questionGroup>\n";
if ($complete) {
$xml .= " <csi:qText>" . self::_xmlentities($question->qText) . "</csi:qText>\n";
}
$xml .= " <csi:questionGUID>" . self::_xmlentities($question->questionGUID) . "</csi:questionGUID>\n";
$xml .= " <csi:seqNumber>" . self::_xmlentities($question->seqNumber) . "</csi:seqNumber>\n";
if ($complete && strlen(self::_xmlentities($question->questionNumber))) {
$xml .= " <csi:groupQuestionNumber>" . self::_xmlentities($question->questionNumber) . "</csi:groupQuestionNumber>\n";
}
$xml .= " <csi:cloneable>" . self::_xmlentities($question->cloneable) . "</csi:cloneable>\n";
$xml .= " <csi:groupDefaultQuestionHidden>" . self::_xmlentities($question->defaultQuestionHidden) . "</csi:groupDefaultQuestionHidden>\n";
$references = $question->references;
if (count($references) > 0) {
$xml .= " <csi:groupQuestionReferences>";
foreach ($references as $reference) {
$xml .= " <csi:reference>\n";
$xml .= " <csi:shortName>" . self::_xmlentities($reference['shortName']) . "</csi:shortName>\n";
$xml .= " <csi:referenceName>" . self::_xmlentities($reference['referenceName']) . "</csi:referenceName>\n";
$xml .= " <csi:item>" . self::_xmlentities($reference['item']) . "</csi:item>\n";
$xml .= " <csi:referenceURL>" . self::_xmlentities($reference['referenceURL']) . "</csi:referenceURL>\n";
$xml .= " <csi:referenceText>" . self::_xmlentities($reference['referenceText']) . "</csi:referenceText>\n";
$xml .= " </csi:reference>\n";
}
$xml .= "</csi:groupQuestionReferences>\n";
}
if (isset($this->attachmentQuestions['QuestionModel'][$question->questionID])) {
$fileObj = new FileModel($question);
$ids = $fileObj->fetchAll();
if (count($ids)) {
$xml .= " <csi:attachments>\n";
foreach ($ids as $id) {
$xml .= " <csi:attachment>\n";
$file = $fileObj->fetchProperties($id);
//.........这里部分代码省略.........
示例3: addAttachments
/**
* Adds all attachments associated with the instance to the zip archive
*/
public function addAttachments()
{
$attachmentQuestions = FileModel::fetchObjectIdsByInstance($this->instance->instanceID);
$instance = new InstanceModel(array('instanceID' => $this->instance->instanceID, 'depth' => 'question'));
while ($page = $instance->nextPage()) {
while ($section = $page->nextSection()) {
while ($question = $section->nextQuestion()) {
if (isset($attachmentQuestions['QuestionModel'][$question->questionID])) {
$fileObj = new FileModel($question);
$ids = $fileObj->fetchAll();
if ($ids === NULL) {
continue;
}
foreach ($ids as $id) {
$file = $fileObj->fetchWithProperties($id);
$this->addFromString("files/{$id}", $file['contents']);
}
}
}
}
}
}