https://www.drupal.org/documentation/entity-metadata-wrappers
$user_wrapper = &entity_metadata_wrapper('user', $user); $status = $user_wrapper->field_status->value(); //取值 array_push($status,'b'); $user_wrapper->field_status->set($status); // set $user_wrapper->save();
<?php
$wrapper = entity_metadata_wrapper('node', $node);
$wrapper->author->mail->value();
$wrapper->author->mail->set('sepp@example.com')
?>
删除数据:
<?php
// Using an empty ->set(NULL) removes the value - without NULL you'll get a PHP notice that set($value) requires 1 parameter.
$wrapper->field_data->set(NULL);
// And handles correctly the deltas when using multiple values fields
$wrapper->field_data[$delta]->set(NULL);
?>
多值字段取值:
<?php
$first_name = $wrapper->field_tags[0]->name->value();
?>
Example using field collections
<?php
// Populate the fields.
$ewrapper = entity_metadata_wrapper('node', $node);
$ewrapper->field_lead_contact_name->set($contact_name);
$ewrapper->field_lead_contact_phone->set($contact_phone);
$ewrapper->field_lead_contact_email->set($contact_email);
// Create the collection entity and set it's "host".
$collection = entity_create('field_collection_item', array('field_name' => 'field_facilities_requested'));
$collection->setHostEntity('node', $node);
// Now define the collection parameters.
$cwrapper = entity_metadata_wrapper('field_collection_item', $collection);
$cwrapper->field_facility->set(intval($offset));
$cwrapper->save();
// Save.
$ewrapper->save();
?>
相关推荐
Entity_Framework_学习 电子书 新手入门的好教程!
这是一个改进,但是您可能会发现自己entity_metadata_wrapper输入entity_metadata_wrapper ! $wrapper = entity_metadata_wrapper('node', $node); 您也可能会想将实体视为对象,并使用自己的自定义方法对其进行...
CCKS2019赛题《面向金融的事件主题》数据,为了方便以后下载,所以上传到CSDN上,因为在查找数据的时候发现只有train数据集,而没有eval数据集,所以上传上去,方便以后学习的时候下载。
这是一本EF的入门书,麻雀虽小,五脏俱全。通过小项目对EF的关键技术如code-first做一个说明,让初学者对EF有个了解。
$ account = entity_metadata_wrapper ( 'user' , $ user );$ account -> employee_number -> set ( 60000 );entity_save ( 'user' , $ account );从用户对象获取数据。 global $ user ;$ account = entity_metadata...
Entity_Framework_Code_First_Succinctly.pdf 国外Entity_Framework_Code_First学习入门与进阶教程,PDF版的 方便学习
Entity_Framework_教程,适合初学者
Entity_Framework学习
Entity_Framework_ѧϰ.doc 适合初到高级的Entity_Framework的使用
DevArt_Entity_Developer_6.4.719_Professional_Downloadly.ir.rar
A_survey_of_named_entity_recognition_and_classification
学习Entity_Framework_实体框架
fine_conf_entity_10
Entity_Framework_6_Power_Tools_Community_Edition_v0.9.126
Entity_Framework_实体框架 很全 很详细 阐述实体架构的实用方法
Entity_Framework_Profiler_v5.0_Build_5033_Downloadly.ir.rar
Entity_41.sql
Entity_framework教程 适合入门
使用Entity_Framework_4进行代码优先开发.