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


PHP Zotero_DB::getTransactionTimestampUnix方法代码示例

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


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

示例1: processDownloadInternal

 private static function processDownloadInternal($userID, $lastsync, DOMDocument $doc, $syncDownloadQueueID = null, $syncDownloadProcessID = null, $params = [])
 {
     $apiVersion = (int) $doc->documentElement->getAttribute('version');
     if ($lastsync == 1) {
         StatsD::increment("sync.process.download.full");
     }
     // TEMP
     $cacheKeyExtra = (!empty($params['ft']) ? json_encode($params['ft']) : "") . (!empty($params['ftkeys']) ? json_encode($params['ftkeys']) : "");
     try {
         $cached = Zotero_Sync::getCachedDownload($userID, $lastsync, $apiVersion, $cacheKeyExtra);
         if ($cached) {
             $doc->loadXML($cached);
             StatsD::increment("sync.process.download.cache.hit");
             return;
         }
     } catch (Exception $e) {
         $msg = $e->getMessage();
         if (strpos($msg, "Too many connections") !== false) {
             $msg = "'Too many connections' from MySQL";
         } else {
             $msg = "'{$msg}'";
         }
         Z_Core::logError("Warning: {$msg} getting cached download");
         StatsD::increment("sync.process.download.cache.error");
     }
     set_time_limit(1800);
     $profile = false;
     if ($profile) {
         $shardID = Zotero_Shards::getByUserID($userID);
         Zotero_DB::profileStart(0);
     }
     if ($syncDownloadQueueID) {
         self::addDownloadProcess($syncDownloadQueueID, $syncDownloadProcessID);
     }
     $updatedNode = $doc->createElement('updated');
     $doc->documentElement->appendChild($updatedNode);
     $userLibraryID = Zotero_Users::getLibraryIDFromUserID($userID);
     $updatedCreators = array();
     try {
         Zotero_DB::beginTransaction();
         // Blocks until any upload processes are done
         $updateTimes = Zotero_Libraries::getUserLibraryUpdateTimes($userID);
         $timestamp = Zotero_DB::getTransactionTimestampUnix();
         $doc->documentElement->setAttribute('timestamp', $timestamp);
         $doc->documentElement->setAttribute('userID', $userID);
         $doc->documentElement->setAttribute('defaultLibraryID', $userLibraryID);
         $updateKey = Zotero_Users::getUpdateKey($userID);
         $doc->documentElement->setAttribute('updateKey', $updateKey);
         // Get libraries with update times >= $timestamp
         $updatedLibraryIDs = array();
         foreach ($updateTimes as $libraryID => $timestamp) {
             if ($timestamp >= $lastsync) {
                 $updatedLibraryIDs[] = $libraryID;
             }
         }
         // Add new and updated groups
         $joinedGroups = Zotero_Groups::getJoined($userID, (int) $lastsync);
         $updatedIDs = array_unique(array_merge($joinedGroups, Zotero_Groups::getUpdated($userID, (int) $lastsync)));
         if ($updatedIDs) {
             $node = $doc->createElement('groups');
             $showGroups = false;
             foreach ($updatedIDs as $id) {
                 $group = new Zotero_Group();
                 $group->id = $id;
                 $xmlElement = $group->toXML($userID);
                 $newNode = dom_import_simplexml($xmlElement);
                 $newNode = $doc->importNode($newNode, true);
                 $node->appendChild($newNode);
                 $showGroups = true;
             }
             if ($showGroups) {
                 $updatedNode->appendChild($node);
             }
         }
         // If there's updated data in any library or
         // there are any new groups (in which case we need all their data)
         $hasData = $updatedLibraryIDs || $joinedGroups;
         if ($hasData) {
             foreach (Zotero_DataObjects::$classicObjectTypes as $syncObject) {
                 $Name = $syncObject['singular'];
                 // 'Item'
                 $Names = $syncObject['plural'];
                 // 'Items'
                 $name = strtolower($Name);
                 // 'item'
                 $names = strtolower($Names);
                 // 'items'
                 $className = 'Zotero_' . $Names;
                 $updatedIDsByLibraryID = call_user_func(array($className, 'getUpdated'), $userID, $lastsync, $updatedLibraryIDs);
                 if ($updatedIDsByLibraryID) {
                     $node = $doc->createElement($names);
                     foreach ($updatedIDsByLibraryID as $libraryID => $ids) {
                         if ($name == 'creator') {
                             $updatedCreators[$libraryID] = $ids;
                         }
                         foreach ($ids as $id) {
                             if ($name == 'item') {
                                 $obj = call_user_func(array($className, 'get'), $libraryID, $id);
                                 $data = array('updatedCreators' => isset($updatedCreators[$libraryID]) ? $updatedCreators[$libraryID] : array());
                                 $xmlElement = Zotero_Items::convertItemToXML($obj, $data, $apiVersion);
//.........这里部分代码省略.........
开发者ID:selenus,项目名称:dataserver,代码行数:101,代码来源:Sync.inc.php


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