PHP Класс 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';
Наследование: implements ArrayAcces\ArrayAccess, use trait DatastoreTrait
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__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.

Описание методов

__construct() публичный Метод

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 __get ( string $property ) : mixed
$property string
Результат mixed

__isset() публичный Метод

public __isset ( string $property ) : boolean
$property string
Результат boolean

__set() публичный Метод

public __set ( string $property, mixed $value ) : void
$property string
$value mixed
Результат void

__unset() публичный Метод

public __unset ( string $property ) : void
$property string
Результат void

baseVersion() публичный Метод

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
Результат string | null

cursor() публичный Метод

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
Результат string | null

excludedProperties() публичный Метод

Example: $excludedFromIndexes = $entity->excludedProperties();
public excludedProperties ( ) : array
Результат array

get() публичный Метод

Example: $data = $entity->get();
public get ( ) : array
Результат array

key() публичный Метод

Example: $key = $entity->key();
public key ( ) : Key
Результат Key

meanings() публичный Метод

Example: $meanings = $entity->meanings();
public meanings ( ) : array
Результат array

offsetExists() публичный Метод

public offsetExists ( string $key ) : boolean
$key string the value to check.
Результат boolean

offsetGet() публичный Метод

public offsetGet ( string $key ) : mixed
$key string the value to retrieve.
Результат mixed

offsetSet() публичный Метод

public offsetSet ( string $key, $val ) : void
$key string The value name.
Результат void

offsetUnset() публичный Метод

public offsetUnset ( string $key ) : void
$key string the value to remove.
Результат void

populatedByService() публичный Метод

Example: $populatedByService = $entity->populatedByService();
public populatedByService ( ) : boolean
Результат boolean

set() публичный Метод

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.
Результат void

setExcludeFromIndexes() публичный Метод

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.
Результат void