You are here

function _salesforce_api_querymore in Salesforce Suite 7.2

Same name and namespace in other branches
  1. 6.2 salesforce_api/salesforce_api.module \_salesforce_api_querymore()

Wraps SforceBaseClient::queryMore. Needs a query locator for an active query and a Salesforce connection, so this must only be called from salesforce_api_query(). Calls itself recursively until records are retrieved.

Parameters

object $queryLocator: The position within the current query from which to begin.

object $sf: The active Salesforce connection.

Return value

array An array of matching records on success, or FALSE on failure.

1 call to _salesforce_api_querymore()
salesforce_api_query in salesforce_api/salesforce_api.module
Wraps SforceBaseClient::query. Queries Salesforce for a record or set of records. For information about SOQL syntax,

File

salesforce_api/salesforce_api.module, line 1609
Defines an API that enables modules to interact with the Salesforce server.

Code

function _salesforce_api_querymore($queryLocator, $sf) {
  if (!is_object($sf)) {
    return FALSE;
  }

  // Execute the queryMore
  try {
    $result = $sf->client
      ->queryMore($queryLocator);
  } catch (Exception $e) {
    salesforce_api_log(SALESFORCE_LOG_ALL, 'Salesforce queryMore failed with exception: ' . $e
      ->getMessage(), array(), WATCHDOG_ERROR);
    return FALSE;
  }

  // Recursively merge results
  $records = $result->records;
  if (!$result->done) {
    $moreRecords = _salesforce_api_querymore($result->queryLocator, $sf);
    if (is_array($moreRecords)) {
      $records = array_merge($records, $moreRecords);
    }
  }
  return $records;
}