コード例 #1
0
 /**
  * Creates new QueryTablesResult object
  * 
  * @param array $headers The HTTP response headers
  * @param array $entries The table entriess
  * 
  * @return \MicrosoftAzure\Storage\Table\Models\QueryTablesResult 
  */
 public static function create($headers, $entries)
 {
     $result = new QueryTablesResult();
     $headers = array_change_key_case($headers);
     $result->setNextTableName(Utilities::tryGetValue($headers, Resources::X_MS_CONTINUATION_NEXTTABLENAME));
     $result->setTables($entries);
     return $result;
 }
コード例 #2
0
 /**
  * @covers MicrosoftAzure\Storage\Table\Models\QueryTablesResult::setTables
  * @covers MicrosoftAzure\Storage\Table\Models\QueryTablesResult::getTables
  */
 public function testSetTables()
 {
     // Setup
     $result = new QueryTablesResult();
     $expected = array(1, 2, 3, 4, 5);
     // Test
     $result->setTables($expected);
     // Assert
     $this->assertEquals($expected, $result->getTables());
 }
コード例 #3
0
 /**
  * Quries tables in the given storage account.
  *
  * @param Models\QueryTablesOptions|string|Models\Filter $options Could be
  * optional parameters, table prefix or filter to apply.
  *
  * @return Models\QueryTablesResult
  *
  * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179405.aspx
  */
 public function queryTables($options = null)
 {
     $method = Resources::HTTP_GET;
     $headers = array();
     $postParams = array();
     $queryParams = array();
     $statusCode = Resources::STATUS_OK;
     $path = 'Tables';
     if (is_null($options)) {
         $options = new QueryTablesOptions();
     } else {
         if (is_string($options)) {
             $prefix = $options;
             $options = new QueryTablesOptions();
             $options->setPrefix($prefix);
         } else {
             if ($options instanceof Filter) {
                 $filter = $options;
                 $options = new QueryTablesOptions();
                 $options->setFilter($filter);
             }
         }
     }
     $query = $options->getQuery();
     $next = $options->getNextTableName();
     $prefix = $options->getPrefix();
     $timeout = $options->getTimeout();
     if (!empty($prefix)) {
         // Append Max char to end '{' is 1 + 'z' in AsciiTable ==> upperBound
         // is prefix + '{'
         $prefixFilter = Filter::applyAnd(Filter::applyGe(Filter::applyPropertyName('TableName'), Filter::applyConstant($prefix, EdmType::STRING)), Filter::applyLe(Filter::applyPropertyName('TableName'), Filter::applyConstant($prefix . '{', EdmType::STRING)));
         if (is_null($query)) {
             $query = new Models\Query();
         }
         if (is_null($query->getFilter())) {
             // use the prefix filter if the query filter is null
             $query->setFilter($prefixFilter);
         } else {
             // combine and use the prefix filter if the query filter exists
             $combinedFilter = Filter::applyAnd($query->getFilter(), $prefixFilter);
             $query->setFilter($combinedFilter);
         }
     }
     $queryParams = $this->_addOptionalQuery($queryParams, $query);
     $this->addOptionalQueryParam($queryParams, Resources::QP_NEXT_TABLE_NAME, $next);
     $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $timeout);
     // One can specify the NextTableName option to get table entities starting
     // from the specified name. However, there appears to be an issue in the
     // Azure Table service where this does not engage on the server unless
     // $filter appears in the URL. The current behavior is to just ignore the
     // NextTableName options, which is not expected or easily detectable.
     if (array_key_exists(Resources::QP_NEXT_TABLE_NAME, $queryParams) && !array_key_exists(Resources::QP_FILTER, $queryParams)) {
         $queryParams[Resources::QP_FILTER] = Resources::EMPTY_STRING;
     }
     $response = $this->send($method, $headers, $queryParams, $postParams, $path, $statusCode);
     $tables = $this->_atomSerializer->parseTableEntries($response->getBody());
     return QueryTablesResult::create(HttpFormatter::formatHeaders($response->getHeaders()), $tables);
 }