-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new "quickstart" samples. #174
Changes from 1 commit
331c184
78c821b
16982ac
8196545
0158ed9
09e2cb1
9340a8b
ac14b65
27e54e5
fd64f8b
124566c
59f9085
21eaaa6
d187637
8850d29
dc00f27
b7bda05
a772cd1
ff6a9c4
eda129e
4a2c81f
bc4e224
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,18 +10,21 @@ | |
# Instantiates a client | ||
$datastore = new DatastoreClient(); | ||
|
||
# The kind of the entity to retrieve | ||
# The kind for the new entity | ||
$kind = 'Task'; | ||
|
||
# The name/ID of the entity to retrieve | ||
# The name/ID for the new entity | ||
$name = 'sampletask1'; | ||
|
||
# The Datastore key for the entity | ||
# The Cloud Datastore key for the new entity | ||
$taskKey = $datastore->key($kind, $name); | ||
|
||
# Retrieves the task | ||
$task = $datastore->lookup($taskKey); | ||
# Prepares the new entity | ||
$task = $datastore->entity($taskKey, ['description' => 'Buy milk']); | ||
|
||
echo 'Fetched task: ' . $task->key(); | ||
# Saves the entity | ||
$datastore->upsert($task); | ||
|
||
echo 'Saved ' . $task->key() . ': ' . $task['description']; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This output will look like this:
A little weird, but seems ok to me :D There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I couldn't for the life of me get it to just print There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. haha yeah, you would have to call |
||
# [END datastore_quickstart] | ||
return $task; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"buymilktask"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah, what would be the point of the description field in that case?