获取实体';数据存储PHP API中的s ID
有没有办法使用PHP数据存储API获取实体的ID/密钥?获取实体';数据存储PHP API中的s ID,php,google-cloud-datastore,Php,Google Cloud Datastore,有没有办法使用PHP数据存储API获取实体的ID/密钥? 我已经对所有内容进行了身份验证,我能够获得值,但没有ID 这是我的密码: <?php $title = "Builder | Makeroid Account"; include "../assets/includes/head.php"; if (!$USER->is_logged_in()) { $USER->redirect('/'); } require
我已经对所有内容进行了身份验证,我能够获得值,但没有ID 这是我的密码:
<?php
$title = "Builder | Makeroid Account";
include "../assets/includes/head.php";
if (!$USER->is_logged_in()) {
$USER->redirect('/');
}
require_once __DIR__.'/../assets/libs/datastore/vendor/autoload.php';
use Google\Cloud\Datastore\DatastoreClient;
use Google\Cloud\Datastore\Query\Query;
$datastore = new DatastoreClient([
'projectId' => 'makeroid-builder'
]);
$query = $datastore->query();
$query->kind('UserData');
$query->filter('emaillower', '=', $U_DATA['email']);
$users = $datastore->runQuery($query);
$params = ["email", "emailFrequency", "emaillower", "isAdmin", "link", "name", "sessionid", "settings", "templatePath", "tosAccepted", "type", "upgradedGCS"];
?>
<div class="content">
<div class="container-fluid">
<div class="row">
<?php foreach ($users as $user) { ?>
<div class="col-md-12">
<div class="card">
<div class="card-header card-header-icon" data-background-color="rose">
<i class="material-icons">assignment</i>
</div>
<div class="card-content">
<h4 class="card-title">User Properties</h4>
<div class="table-responsive">
<table class="table">
<thead class="text-primary">
<th>Key</th>
<th>Value</th>
</thead>
<tbody>
<?php print_r($user); foreach ($params as $param) { ?>
<tr>
<td><?=$param?></td>
<td><?=$user?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
<?php include "../assets/includes/footer.php"; ?>
分配
用户属性
钥匙
价值
我想得到这个:
我能够获取行中的所有值,例如我的电子邮件,但我没有找到获取该ID的方法我尝试过使用
$user['id']
,$user['key']
或$user['''''key']
,但它们都不起作用您需要从实体()中提取密钥,然后使用类似$key->pathEndIdentifier()的东西从密钥()中提取id
因此,与其尝试将键作为字典值从对象中取出,不如尝试将其作为方法取出$用户->键()->pathEndIdentifier()