Offset() 공개 메소드

Sets the statement OFFSET clause in the form of

"OFFSET <count>"

e.g. 200.
public Offset ( integer $count ) : StatementBuilder
$count integer the statement offset
리턴 StatementBuilder a reference to this object
    $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) {
 /**
  * @covers StatementBuilder::ToStatement
  * @expectedException ValidationException
  */
 public function testToStatementOffsetWithoutLimit()
 {
     $statementBuilder = new StatementBuilder();
     $statementBuilder->Offset(500)->ToStatement();
 }