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


PHP StatementBuilder::Offset方法代码示例

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


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

示例1: getPredefinedCustomTargetingKeyIds

    $user->LogDefaults();
    // Get the CustomTargetingService.
    $customTargetingService = $user->GetService('CustomTargetingService', 'v201508');
    // Get all predefined custom targeting keys.
    $customTargetingKeyIds = getPredefinedCustomTargetingKeyIds($user);
    // Create a statement to get all custom targeting values for a custom
    // targeting key.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->Where('customTargetingKeyId = :customTargetingKeyId')->OrderBy('id ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT);
    $totalResultsCounter = 0;
    foreach ($customTargetingKeyIds as $customTargetingKeyId) {
        // Set the custom targeting key ID to select from.
        $statementBuilder->WithBindVariableValue('customTargetingKeyId', $customTargetingKeyId);
        // Default for total result set size and offset.
        $totalResultSetSize = 0;
        $statementBuilder->Offset(0);
        do {
            // Get custom targeting values by statement.
            $page = $customTargetingService->getCustomTargetingValuesByStatement($statementBuilder->ToStatement());
            // Display results.
            if (isset($page->results)) {
                $totalResultSetSize = $page->totalResultSetSize;
                foreach ($page->results as $customTargetingValue) {
                    printf("%d) Custom targeting value with ID %d, belonging to key with " . "ID %d, name '%s', and display name '%s' was found.\n", $totalResultsCounter++, $customTargetingValue->id, $customTargetingValue->customTargetingKeyId, $customTargetingValue->name, $customTargetingValue->displayName);
                }
            }
            $statementBuilder->IncreaseOffsetBy(StatementBuilder::SUGGESTED_PAGE_LIMIT);
        } while ($statementBuilder->GetOffset() < $totalResultSetSize);
    }
    printf("Number of results found: %d\n", $totalResultsCounter);
} catch (OAuth2Exception $e) {
开发者ID:stevenmaguire,项目名称:googleads-php-lib,代码行数:31,代码来源:GetPredefinedCustomTargetingKeysAndValues.php

示例2: testToStatementOffsetWithoutLimit

 /**
  * @covers StatementBuilder::ToStatement
  * @expectedException ValidationException
  */
 public function testToStatementOffsetWithoutLimit()
 {
     $statementBuilder = new StatementBuilder();
     $statementBuilder->Offset(500)->ToStatement();
 }
开发者ID:googleads,项目名称:googleads-php-lib,代码行数:9,代码来源:StatementBuilderTest.php


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