Google\Cloud\Datastore\DatastoreClient::lookup PHP Method

lookup() public method

To lookup an entity inside a transaction, use {@see \Google\Cloud\Datastore\Transaction::lookup()}. Example: $key = $datastore->key('Person', 'Bob'); $entity = $datastore->lookup($key); if (!is_null($entity)) { echo $entity['firstName']; // 'Bob' }
public lookup ( Key $key, array $options = [] ) : Entity | null
$key Key The identifier to use to locate a desired entity.
$options array [optional] { Configuration Options @type string $readConsistency See [ReadConsistency](https://cloud.google.com/datastore/reference/rest/v1/ReadOptions#ReadConsistency). @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 Entity | null
    public function lookup(Key $key, array $options = [])
    {
        $res = $this->lookupBatch([$key], $options);
        return isset($res['found'][0]) ? $res['found'][0] : null;
    }