You are here

function drush_salesforce_sf_execute_query in Salesforce Suite 8.4

Same name and namespace in other branches
  1. 8.3 salesforce.drush.inc \drush_salesforce_sf_execute_query()
  2. 7.3 salesforce.drush.inc \drush_salesforce_sf_execute_query()
  3. 5.0.x salesforce.drush.inc \drush_salesforce_sf_execute_query()

Execute a SOQL query.

Parameters

string $query: The query to execute.

File

./salesforce.drush.inc, line 437
Drush integration for Salesforce.

Code

function drush_salesforce_sf_execute_query($query = NULL) {
  _drush_salesforce_deprecated();
  if (!$query) {
    drush_log('Please specify a query as an argument.', 'error');
    return;
  }
  $salesforce = \Drupal::service('salesforce.client');
  try {
    $result = $salesforce
      ->apiCall('query?q=' . urlencode($query));
    drush_print(drush_format($result));
  } catch (SalesforceException $e) {
    drush_log($e
      ->getMessage(), 'error');
  }
}