在app引擎中使用php为实体设置数据存储区父级

时间:2014-04-13 00:05:50

标签: php google-app-engine google-cloud-datastore

有没有人知道如何在php中为数据存储区实体设置父级以构建层次结构?不幸的是谷歌云仍然没有发布任何文档使用PHP中的数据存储,使PHP无用,除了一个博客网站上没有其他资源。

1 个答案:

答案 0 :(得分:0)

我刚刚发布了PHP的数据存储库的第一个版本,这使得这非常简单。

https://github.com/tomwalder/php-gds

'examples'文件夹中有一些代码示例,但它看起来有点像这样(我会跳过样板文件)......

// Grab the parent Entity from Datastore
$obj_will_shakespeare = $obj_author_store->fetchOne();

// Create the child
$obj_book = new GDS\Entity();
$obj_book->title = 'Romeo and Juliet';
$obj_book->isbn = '1840224339';

// Set the parent 
$obj_book->setAncestry($obj_will_shakespeare);

// Write the child to Datastore
$obj_book_store->upsert($obj_book);

此语法还支持多个嵌套级别。

相关问题