You are here

class QueryResult in Salesforce Suite 5.0.x

Same name and namespace in other branches
  1. 8.4 src/Commands/QueryResult.php \Drupal\salesforce\Commands\QueryResult
  2. 8.3 src/Commands/QueryResult.php \Drupal\salesforce\Commands\QueryResult

Adds structured metadata to RowsOfFieldsWithMetadata.

Hierarchy

  • class \Drupal\salesforce\Commands\QueryResult extends \Consolidation\OutputFormatters\StructuredData\RowsOfFieldsWithMetadata

Expanded class hierarchy of QueryResult

1 file declares its use of QueryResult
SalesforceMappingCommandsBase.php in modules/salesforce_mapping/src/Commands/SalesforceMappingCommandsBase.php

File

src/Commands/QueryResult.php, line 12

Namespace

Drupal\salesforce\Commands
View source
class QueryResult extends RowsOfFieldsWithMetadata {

  /**
   * Size of query result.
   *
   * @var int
   */
  protected $size;

  /**
   * Total records returned by query.
   *
   * @var int
   */
  protected $total;

  /**
   * The query.
   *
   * @var \Drupal\salesforce\SelectQueryInterface
   */
  protected $query;

  /**
   * QueryResult constructor.
   *
   * @param \Drupal\salesforce\SelectQueryInterface $query
   *   SOQL query.
   * @param \Drupal\salesforce\SelectQueryResult $queryResult
   *   SOQL result.
   */
  public function __construct(SelectQueryInterface $query, SelectQueryResult $queryResult) {
    $data = [];
    foreach ($queryResult
      ->records() as $id => $record) {
      $data[$id] = $record
        ->fields();
    }
    parent::__construct($data);
    $this->size = count($queryResult
      ->records());
    $this->total = $queryResult
      ->size();
    $this->query = $query;
  }

  /**
   * Getter for query size (total number of records returned).
   *
   * @return int
   *   The size.
   */
  public function getSize() {
    return $this->size;
  }

  /**
   * Getter for query total (total number of records available).
   *
   * @return mixed
   *   The total.
   */
  public function getTotal() {
    return $this->total;
  }

  /**
   * Getter for query.
   *
   * @return \Drupal\salesforce\SelectQuery
   *   The query.
   */
  public function getQuery() {
    return $this->query;
  }

  /**
   * Get a prettified query.
   *
   * @return string
   *   Strip '+' escaping from the query.
   */
  public function getPrettyQuery() {
    return str_replace('+', ' ', (string) $this->query);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
QueryResult::$query protected property The query.
QueryResult::$size protected property Size of query result.
QueryResult::$total protected property Total records returned by query.
QueryResult::getPrettyQuery public function Get a prettified query.
QueryResult::getQuery public function Getter for query.
QueryResult::getSize public function Getter for query size (total number of records returned).
QueryResult::getTotal public function Getter for query total (total number of records available).
QueryResult::__construct public function QueryResult constructor.