如何创建与父母使用的实体gcloud
,datastore
以及nodejs
?
如何搜索给定父级的所有实体?
像(这不起作用):
var path = [{kind: 'Parent', id: parentId}, {kind: 'Me'}];
var key = ds.key(path);
var entity = {
key: key,
data: toDatastore(data, ['description'])
};
ds.save(entity)
Run Code Online (Sandbox Code Playgroud)
阅读文档我没有找到任何创建具有给定父级的实体的示例.我在这里搜索(没有成功):https: //googlecloudplatform.github.io/gcloud-node/#/docs/v0.19.1
而在python中的对应物上有一些特定的属性来指定父实体:http: //googlecloudplatform.github.io/gcloud-python/latest/datastore-keys.html
请提供有关如何使用父级创建和搜索实体的代码示例
我正处于这样一种情况,我想构建一个$bindParam
以这种格式变量的代码:
$bindParams = [$type1 => $param1, $type2 => $param2, ... ]
Run Code Online (Sandbox Code Playgroud)
我想构建一些代码,动态地将这些参数添加到预准备语句中.
这是我到目前为止构建的代码:
$mysql = new mysqli("localhost", "root", "", "db1");
$stmt = $mysql->prepare($sql);
foreach($bindParams as $type => $data) {
$stmt->bind_param($type, $data);
}
$stmt->execute();
$result = $stmt->get_result();
// and after perhaps twiddling with the result set, but this is not the case .....
Run Code Online (Sandbox Code Playgroud)
对于你的实例
$sql = "INSERT INTO table1 (name, age) VALUES (?,?);"
Run Code Online (Sandbox Code Playgroud)
和
$bindParams = ["s" => "hello", "i" => 15]
Run Code Online (Sandbox Code Playgroud)
这并不总是有这样的结构,它可以改变为例如$bindParams = ["s" => "hello", "i" …