PHP Class Google\Cloud\Datastore\Entity

Entity implements PHP's ArrayAccess, allowing access via the array syntax (example below). Properties are mapped automatically to their corresponding Datastore value types. Refer to the table below for a guide to how types are stored. | **PHP Type** | **Datastore Value Type** | |--------------------------------------------|--------------------------------------| | \DateTimeInterface | timestampValue | | {@see \Google\Cloud\Datastore\Key} | keyValue | | {@see \Google\Cloud\Datastore\GeoPoint} | geoPointValue | | {@see \Google\Cloud\Datastore\Entity} | entityValue | | {@see \Google\Cloud\Datastore\Blob} | blobValue | | {@see \Google\Cloud\Int64} | integerValue | | Associative Array | entityValue (No Key) | | Non-Associative Array | arrayValue | | float | doubleValue | | int | integerValue | | string | stringValue | | resource | blobValue | | NULL | nullValue | | bool | booleanValue | | object (Outside types specified above) | **ERROR** InvalidArgumentException | Example: use Google\Cloud\ServiceBuilder; $cloud = new ServiceBuilder(); $datastore = $cloud->datastore(); $key = $datastore->key('Person', 'Bob'); $entity = $datastore->entity($key, [ 'firstName' => 'Bob', 'lastName' => 'Testguy' ]); echo $entity['firstName']; // 'Bob' $entity['location'] = 'Detroit, MI';
Inheritance: implements ArrayAcces\ArrayAccess, use trait DatastoreTrait
Afficher le fichier Open project: GoogleCloudPlatform/gcloud-php Class Usage Examples

Méthodes publiques

Méthode Description
__construct ( Key $key, array $entity = [], array $options = [] )
__get ( string $property ) : mixed
__isset ( string $property ) : boolean
__set ( string $property, mixed $value ) : void
__unset ( string $property ) : void
baseVersion ( ) : string | null Fetch the baseVersion
cursor ( ) : string | null Fetch the cursor
excludedProperties ( ) : array Return a list of properties excluded from datastore indexes
get ( ) : array Get the entity data
key ( ) : Key Get the Entity Key
meanings ( ) : array return a list of meaning values
offsetExists ( string $key ) : boolean
offsetGet ( string $key ) : mixed
offsetSet ( string $key, $val ) : void
offsetUnset ( string $key ) : void
populatedByService ( ) : boolean Indicate whether the entity was created as the result of an API call.
set ( array $entity ) : void Set the entity data
setExcludeFromIndexes ( array $properties ) : void A list of entity properties to exclude from datastore indexes.

Method Details

__construct() public méthode

public __construct ( Key $key, array $entity = [], array $options = [] )
$key Key The Entity's Key, defining its unique identifier.
$entity array [optional] The entity body.
$options array [optional] { Configuration Options @type string $cursor Set only when the entity is obtained by a query result. If set, the entity cursor can be retrieved from {@see \Google\Cloud\Datastore\Entity::cursor()}. @type string $baseVersion Set only when the entity is obtained by a query result. If set, the entity cursor can be retrieved from {@see \Google\Cloud\Datastore\Entity::baseVersion()}. @type array $excludeFromIndexes A list of entity keys to exclude from datastore indexes. @type array $meanings A list of meaning values for entity properties. @type bool $populatedByService Indicates whether the entity was created as the result of a service request. }

__get() public méthode

public __get ( string $property ) : mixed
$property string
Résultat mixed

__isset() public méthode

public __isset ( string $property ) : boolean
$property string
Résultat boolean

__set() public méthode

public __set ( string $property, mixed $value ) : void
$property string
$value mixed
Résultat void

__unset() public méthode

public __unset ( string $property ) : void
$property string
Résultat void

baseVersion() public méthode

This is only set when the entity was obtained from a query result. It is used for concurrency control internally. Example: $baseVersion = $entity->baseVersion();
public baseVersion ( ) : string | null
Résultat string | null

cursor() public méthode

This is only set when the entity was obtained from a query result. It can be used to manually paginate results. Example: $cursor = $entity->cursor();
public cursor ( ) : string | null
Résultat string | null

excludedProperties() public méthode

Example: $excludedFromIndexes = $entity->excludedProperties();
public excludedProperties ( ) : array
Résultat array

get() public méthode

Example: $data = $entity->get();
public get ( ) : array
Résultat array

key() public méthode

Example: $key = $entity->key();
public key ( ) : Key
Résultat Key

meanings() public méthode

Example: $meanings = $entity->meanings();
public meanings ( ) : array
Résultat array

offsetExists() public méthode

public offsetExists ( string $key ) : boolean
$key string the value to check.
Résultat boolean

offsetGet() public méthode

public offsetGet ( string $key ) : mixed
$key string the value to retrieve.
Résultat mixed

offsetSet() public méthode

public offsetSet ( string $key, $val ) : void
$key string The value name.
Résultat void

offsetUnset() public méthode

public offsetUnset ( string $key ) : void
$key string the value to remove.
Résultat void

populatedByService() public méthode

Example: $populatedByService = $entity->populatedByService();
public populatedByService ( ) : boolean
Résultat boolean

set() public méthode

Calling this method replaces the entire entity body. To add or modify a single value on the entity, use the array syntax for assignment. Example: $entity->set([ 'firstName' => 'Dave' ]);
public set ( array $entity ) : void
$entity array The new entity body.
Résultat void

setExcludeFromIndexes() public méthode

Example: $entity['birthDate'] = new DateTime('December 31, 1969'); $entity->setExcludeFromIndexes([ 'birthDate' ]);
public setExcludeFromIndexes ( array $properties ) : void
$properties array A list of properties to exclude from indexes.
Résultat void