【发布时间】:2015-03-15 22:00:49
【问题描述】:
对于一个项目,我使用 Google App Engine 的 Datastore 和 PHP,它没有官方文档。
我使用以下指南成功地将新实体添加到数据存储区,但现在我正在努力让查询正常工作,以便我可以检索数据并将其显示在我的网页上。 https://gae-php-tips.appspot.com/2013/12/23/getting-started-with-the-cloud-datastore-on-php-app-engine/
这是我当前的代码:
try {
// test the config and connectivity by creating a test entity, building
// a commit request for that entity, and creating/updating it in the datastore
// $req = createRequest();
// $service_dataset->commit($dataset_id, $req, []);
$req = createQuery();
// printQueryResults($req);
}
catch (Google_Exception $ex) {
syslog(LOG_WARNING, 'Commit to Cloud Datastore exception: ' . $ex->getMessage());
echo "There was an issue -- check the logs.";
return;
}
function createQuery()
{
$gql_query = new Google_Service_Datastore_GqlQuery();
$gql_query->setQueryString("SELECT * FROM 'Notes' WHERE name = 'test1'");
$gql_query->setAllowLiteral(true);
$req = new Google_Service_Datastore_RunQueryRequest();
$req->setGqlQuery($gql_query);
return $req;
}
我希望能够查询我的数据存储并获取具有匹配名称的所有实体。
【问题讨论】:
标签: php google-app-engine google-cloud-datastore