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';