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


PHP DataProvider::getStudyChunk方法代碼示例

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


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

示例1: script

<?php

/**
  It became apparent, that generating the JSON files export/download/$study.json
  can be quite expansive, and may fail on our server iff memory or time consumption grow too high.
  This is also documented in #237.
  To combat this problem this script (re-)generates all the JSON files as necessary.
*/
chdir(__DIR__);
require_once '../config.php';
require_once '../query/cacheProvider.php';
chdir('..');
echo "Regenerating Study Cache:\n";
foreach (DataProvider::getStudies() as $study) {
    if (CacheProvider::hasCache($study)) {
        continue;
    }
    echo "{$study}..\n";
    $chunk = DataProvider::getStudyChunk($study);
    CacheProvider::setCache($study, json_encode($chunk));
}
echo "Done.\n";
開發者ID:pombredanne,項目名稱:soundcomparisons,代碼行數:22,代碼來源:regenerateCache.php

示例2:

  1.: We offer a list of studies, and also global data applying to each study.
  2.: Each study can be fetched separately.
  3.: JavaScript will tack a timestamp on each study,
      so that we can drop older studies from localStorage,
      in case that we're running out of space.
  4.: The data for each study thus consists of the following things:
      - Name and basic data for the study itself
      - A list of Families in the Study
      - A list of Regions per Family
      - A list of Languages per Region
      - A list of Words per Study
      - A list of Transcriptions per pair of Word and Language
      - Defaults for the Study
*/
if (array_key_exists('global', $_GET)) {
    echo Config::toJSON(array('studies' => DataProvider::getStudies(), 'global' => DataProvider::getGlobal()));
} else {
    if (array_key_exists('study', $_GET)) {
        if (CacheProvider::hasCache($_GET['study'])) {
            echo CacheProvider::getCache($_GET['study']);
        } else {
            $ret = DataProvider::getStudyChunk($_GET['study']);
            //Done:
            $data = json_encode($ret);
            echo $data;
            CacheProvider::setCache($_GET['study'], $data);
        }
    } else {
        echo json_encode(array('lastUpdate' => DataProvider::getLastImport(), 'Description' => 'Add a global parameter to fetch global data, ' . 'and add a study parameter to fetch a study.'));
    }
}
開發者ID:pombredanne,項目名稱:soundcomparisons,代碼行數:31,代碼來源:data.php


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