首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Entity_extract_ids的使用($entity_type,$entity)

Entity_extract_ids的使用($entity_type,$entity)
EN

Stack Overflow用户
提问于 2012-07-05 23:14:32
回答 1查看 953关注 0票数 0

我正在尝试使用entity_extract_ids($entity_type,$entity),其中:

$entity_type =实体类型;例如“节点”或“用户”。

$entity =从中提取值的实体。

我从未使用过这个函数,也不知道第二个参数(即$entity)应该是什么。

我希望看到一个使用此函数的示例代码。谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-07-06 10:45:05

此函数返回array($id, $vid, $bundle);

示例:

代码语言:javascript
复制
// Define $entity_type.
// Could be 'node', 'user', 'file', 'taxonomy_term' etc.
$entity_type = 'node';

// Get $entity object, in our case $node with nid = 1
$entity = node_load(1);

// print_r will give us something like:
// Array
// (
//     [0] => 1
//     [1] => 4
//     [2] => page
// )
// Where [0] is nid, [1] is vid and [2] is bundle name of a node with nid = 1
print_r(entity_extract_ids($entity_type, $entity));

最好像这样使用函数:

代码语言:javascript
复制
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11353800

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档