Drupal 7 如何使用entity\u get\u controller获取新创建实体的实体id
我在下面的drupal a中创建新实体Drupal 7 如何使用entity\u get\u controller获取新创建实体的实体id,drupal-7,Drupal 7,我在下面的drupal a中创建新实体 $entity = new stdClass(); $entity->type = 'entity_type'; $entity->id = 0; $entity->title = 'Entity Title'; //Add data to fields $entity->field_introduction = array ( 'und' => array
$entity = new stdClass();
$entity->type = 'entity_type';
$entity->id = 0;
$entity->title = 'Entity Title';
//Add data to fields
$entity->field_introduction = array
(
'und' => array
(
"0" => array
(
'value' => $strIntroduction
)
)
);
.
.
.
.
//After adding all the fields, I am saving entity as follows,
entity_get_controller('summary_report')->save($entity);
实体已成功保存。在此之后,我需要实体id来进行进一步的操作。如何获取新创建的实体id。
$entity
将包含您的id,因为保存实体后,对象将填充所有数据。从save()
方法返回的数据是TRUE
或FALSE
。希望这有帮助