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


PHP Zend_Service_WindowsAzure_Storage_TableEntity::getTimestamp方法代碼示例

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


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

示例1: _changeEntity

 /**
  * Update entity / merge entity
  * 
  * @param string                              $httpVerb    HTTP verb to use (PUT = update, MERGE = merge)
  * @param string                              $tableName   Table name
  * @param Zend_Service_WindowsAzure_Storage_TableEntity $entity      Entity to update
  * @param boolean                             $verifyEtag  Verify etag of the entity (used for concurrency)
  * @throws Zend_Service_WindowsAzure_Exception
  */
 protected function _changeEntity($httpVerb = Zend_Http_Client::PUT, $tableName = '', Zend_Service_WindowsAzure_Storage_TableEntity $entity = null, $verifyEtag = false)
 {
     if ($tableName === '') {
         throw new Zend_Service_WindowsAzure_Exception('Table name is not specified.');
     }
     if ($entity === null) {
         throw new Zend_Service_WindowsAzure_Exception('Entity is not specified.');
     }
     // Add header information
     $headers = array();
     $headers['Content-Type'] = 'application/atom+xml';
     $headers['Content-Length'] = 0;
     if (!$verifyEtag) {
         $headers['If-Match'] = '*';
     } else {
         $headers['If-Match'] = $entity->getEtag();
     }
     // Generate request body
     $requestBody = '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
                     <entry xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
                       <title />
                       <updated>{tpl:Updated}</updated>
                       <author>
                         <name />
                       </author>
                       <id />
                       <content type="application/xml">
                         <m:properties>
                           {tpl:Properties}
                         </m:properties>
                       </content>
                     </entry>';
     // Attempt to get timestamp from entity
     $timestamp = $entity->getTimestamp();
     if ($timestamp == Zend_Service_WindowsAzure_Storage_TableEntity::DEFAULT_TIMESTAMP) {
         $timestamp = $this->isoDate();
     }
     $requestBody = $this->_fillTemplate($requestBody, array('Updated' => $timestamp, 'Properties' => $this->_generateAzureRepresentation($entity)));
     // Add header information
     $headers = array();
     $headers['Content-Type'] = 'application/atom+xml';
     if (!$verifyEtag) {
         $headers['If-Match'] = '*';
     } else {
         $headers['If-Match'] = $entity->getEtag();
     }
     // Perform request
     $response = null;
     if ($this->isInBatch()) {
         $this->getCurrentBatch()->enlistOperation($tableName . '(PartitionKey=\'' . $entity->getPartitionKey() . '\',RowKey=\'' . $entity->getRowKey() . '\')', '', $httpVerb, $headers, true, $requestBody);
         return null;
     } else {
         $response = $this->_performRequest($tableName . '(PartitionKey=\'' . $entity->getPartitionKey() . '\',RowKey=\'' . $entity->getRowKey() . '\')', '', $httpVerb, $headers, true, $requestBody);
     }
     if ($response->isSuccessful()) {
         // Update properties
         $entity->setEtag($response->getHeader('Etag'));
         $entity->setTimestamp($response->getHeader('Last-modified'));
         return $entity;
     } else {
         throw new Zend_Service_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
     }
 }
開發者ID:hirentricore,項目名稱:devmagento,代碼行數:72,代碼來源:Table.php


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