本文整理汇总了PHP中StatementBuilder::GetOffset方法的典型用法代码示例。如果您正苦于以下问题:PHP StatementBuilder::GetOffset方法的具体用法?PHP StatementBuilder::GetOffset怎么用?PHP StatementBuilder::GetOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StatementBuilder
的用法示例。
在下文中一共展示了StatementBuilder::GetOffset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DfpUser
$user = new DfpUser();
// Log SOAP XML request and response.
$user->LogDefaults();
// Get the ContentService.
$contentService = $user->GetService('ContentService', 'v201408');
// Create a statement to select all content.
$statementBuilder = new StatementBuilder();
$statementBuilder->OrderBy('id ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT);
// Default for total result set size.
$totalResultSetSize = 0;
do {
// Get content by statement.
$page = $contentService->getContentByStatement($statementBuilder->ToStatement());
// Display results.
if (isset($page->results)) {
$totalResultSetSize = $page->totalResultSetSize;
$i = $page->startIndex;
foreach ($page->results as $content) {
printf("%d) Content with ID %d, name '%s', and status %s was found.\n", $i++, $content->id, $content->name, $content->status);
}
}
$statementBuilder->IncreaseOffsetBy(StatementBuilder::SUGGESTED_PAGE_LIMIT);
} while ($statementBuilder->GetOffset() < $totalResultSetSize);
printf("Number of results found: %d\n", $totalResultSetSize);
} catch (OAuth2Exception $e) {
ExampleUtils::CheckForOAuth2Errors($e);
} catch (ValidationException $e) {
ExampleUtils::CheckForOAuth2Errors($e);
} catch (Exception $e) {
printf("%s\n", $e->getMessage());
}
示例2: StatementBuilder
// Log SOAP XML request and response.
$user->LogDefaults();
$pqlService = $user->GetService('PublisherQueryLanguageService', 'v201608');
// Create statement to select all programmatic buyers.
$statementBuilder = new StatementBuilder();
$statementBuilder->Select('BuyerAccountId, Name')->From('Programmatic_Buyer')->OrderBy('BuyerAccountId ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT);
// Retrieve a small amount of rows at a time, paging through until all rows
// have been retrieved.
$resultSet = null;
$combinedResultSet = null;
$i = 0;
do {
$resultSet = $pqlService->select($statementBuilder->ToStatement());
// Combine result sets with previous ones.
$combinedResultSet = $combinedResultSet !== null ? $resultSet : Pql::CombineResultSets($combinedResultSet, $resultSet);
printf("%d) %d programmatic buyers beginning at offset %d were found.\n", $i++, $resultSet->rows !== null ? count($resultSet->rows) : 0, $statementBuilder->GetOffset());
$statementBuilder->IncreaseOffsetBy(StatementBuilder::SUGGESTED_PAGE_LIMIT);
} while ($resultSet->rows !== null && count($resultSet->rows) > 0);
// Change to another file location if desired.
$filePath = sprintf("%s/programmatic-buyers-%s.csv", sys_get_temp_dir(), uniqid());
$fp = fopen($filePath, 'w');
// Write the result set to a CSV.
fputcsv($fp, Pql::GetColumnLabels($combinedResultSet));
foreach ($combinedResultSet->rows as $row) {
fputcsv($fp, Pql::GetRowStringValues($row));
}
fclose($fp);
printf("Programmatic buyers saved to %s\n", $filePath);
} catch (OAuth2Exception $e) {
ExampleUtils::CheckForOAuth2Errors($e);
} catch (ValidationException $e) {
示例3: StatementBuilder
$user->LogDefaults();
// Get the PublisherQueryLanguageService.
$pqlService = $user->GetService('PublisherQueryLanguageService', 'v201508');
// Create statement to select all line items.
$statementBuilder = new StatementBuilder();
$statementBuilder->Select('Id, BrowserName, MajorVersion, MinorVersion')->From('Browser')->OrderBy('BrowserName ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT);
// Default for result sets.
$resultSet = null;
$combinedResultSet = null;
$i = 0;
do {
// Get all browsers.
$resultSet = $pqlService->select($statementBuilder->ToStatement());
// Combine result sets with previous ones.
$combinedResultSet = !isset($combinedResultSet) ? $resultSet : Pql::CombineResultSets($combinedResultSet, $resultSet);
printf("%d) %d browsers beginning at offset %d were found.\n", $i++, isset($resultSet->rows) ? count($resultSet->rows) : 0, $statementBuilder->GetOffset());
$statementBuilder->IncreaseOffsetBy(StatementBuilder::SUGGESTED_PAGE_LIMIT);
} while (isset($resultSet->rows) && count($resultSet->rows) > 0);
// Change to your file location.
$filePath = sprintf("%s/Browsers-%s.csv", sys_get_temp_dir(), uniqid());
$fp = fopen($filePath, 'w');
// Write the result set to a CSV.
fputcsv($fp, Pql::GetColumnLabels($combinedResultSet));
foreach ($combinedResultSet->rows as $row) {
fputcsv($fp, Pql::GetRowStringValues($row));
}
fclose($fp);
printf("Browsers saved to %s\n", $filePath);
} catch (OAuth2Exception $e) {
ExampleUtils::CheckForOAuth2Errors($e);
} catch (ValidationException $e) {
示例4: getPredefinedCustomTargetingKeyIds
/**
* Gets predefined custom targeting key IDs.
*/
function getPredefinedCustomTargetingKeyIds($user)
{
$customTargetingKeyIds = array();
// Get the CustomTargetingService.
$customTargetingService = $user->GetService('CustomTargetingService', 'v201508');
// Create a statement to get predefined custom targeting keys.
$statementBuilder = new StatementBuilder();
$statementBuilder->Where('type = :type')->OrderBy('id ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT)->WithBindVariableValue('type', 'PREDEFINED');
// Default for total result set size.
$totalResultSetSize = 0;
do {
// Get custom targeting keys by statement.
$page = $customTargetingService->getCustomTargetingKeysByStatement($statementBuilder->ToStatement());
// Display results.
if (isset($page->results)) {
$totalResultSetSize = $page->totalResultSetSize;
$i = $page->startIndex;
foreach ($page->results as $customTargetingKey) {
printf("%d) Custom targeting key with ID %d, name '%s', and display " . "name '%s' was found.\n", $i++, $customTargetingKey->id, $customTargetingKey->name, $customTargetingKey->displayName);
$customTargetingKeyIds[] = $customTargetingKey->id;
}
}
$statementBuilder->IncreaseOffsetBy(StatementBuilder::SUGGESTED_PAGE_LIMIT);
} while ($statementBuilder->GetOffset() < $totalResultSetSize);
return $customTargetingKeyIds;
}
开发者ID:stevenmaguire,项目名称:googleads-php-lib,代码行数:29,代码来源:GetPredefinedCustomTargetingKeysAndValues.php