This class is used by {@see \Google\Cloud\Datastore\DatastoreClient} and {@see \Google\Cloud\Datastore\Transaction} and is not intended to be used directly. Examples are omitted for brevity. Detailed usage examples can be found in {@see \Google\Cloud\Datastore\DatastoreClient} and {@see \Google\Cloud\Datastore\Transaction}.
Inheritance: use trait DatastoreTrait, use trait Google\Cloud\ValidateTrait
 public function testKeyWithNamespaceIdOverride()
 {
     $op = new Operation($this->connection->reveal(), 'foo', 'namespace', $this->mapper);
     $key = $op->key('Person', 'Bob', ['namespaceId' => 'otherNamespace']);
     $obj = $key->keyObject();
     $this->assertEquals('otherNamespace', $obj['partitionId']['namespaceId']);
 }
Ejemplo n.º 2
0
 /**
  * Roll back a Transaction
  *
  * Example:
  * ```
  * $transaction->rollback();
  * ```
  *
  * @return void
  */
 public function rollback()
 {
     return $this->operation->rollback($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);
 }