runQuery() public method

Run a query and return entities
public runQuery ( Google\Cloud\Datastore\Query\QueryInterface $query, array $options = [] ) : Generator
$query Google\Cloud\Datastore\Query\QueryInterface The query object.
$options array [optional] { Configuration Options @type string $transaction The transaction ID, if the query should be run in a transaction. @type string $className The name of the class to return results as. Must be a subclass of {@see \Google\Cloud\Datastore\Entity}. If not set, {@see \Google\Cloud\Datastore\Entity} will be used. @type string $readConsistency See [ReadConsistency](https://cloud.google.com/datastore/reference/rest/v1/ReadOptions#ReadConsistency). }
return Generator
Beispiel #1
0
 /**
  * Run a query and return entities inside a Transaction
  *
  * Example:
  * ```
  * $result = $transaction->runQuery($query);
  *
  * foreach ($result as $entity) {
  *     echo $entity['firstName'];
  * }
  * ```
  *
  * @param QueryInterface $query The query object.
  * @param array $options [optional] {
  *     Configuration Options
  *
  *     @type string $className The name of the class to return results as.
  *           Must be a subclass of {@see Google\Cloud\Datastore\Entity}.
  *           If not set, {@see Google\Cloud\Datastore\Entity} will be used.
  * }
  * @return \Generator<Google\Cloud\Datastore\Entity>
  */
 public function runQuery(QueryInterface $query, array $options = [])
 {
     return $this->operation->runQuery($query, $options + ['transaction' => $this->transactionId]);
 }
 /**
  * Run a query and return entities
  *
  * To query datastore inside a transaction, use
  * {@see Google\Cloud\Datastore\Transaction::runQuery()}.
  *
  * Example:
  * ```
  * $result = $datastore->runQuery($query);
  *
  * foreach ($result as $entity) {
  *     echo $entity['firstName'];
  * }
  * ```
  *
  * @param QueryInterface $query A query object.
  * @param array $options [optional] {
  *     Configuration Options
  *
  *     @type string $className The name of the class to return results as.
  *           Must be a subclass of {@see Google\Cloud\Datastore\Entity}.
  *           If not set, {@see Google\Cloud\Datastore\Entity} will be used.
  *     @type string $readConsistency See
  *           [ReadConsistency](https://cloud.google.com/datastore/reference/rest/v1/ReadOptions#ReadConsistency).
  * }
  * @return \Generator<Google\Cloud\Datastore\Entity>
  */
 public function runQuery(QueryInterface $query, array $options = [])
 {
     return $this->operation->runQuery($query, $options);
 }