当前位置: 首页>>代码示例>>PHP>>正文


PHP EEM_Base::get_field_containing_related_model_name方法代码示例

本文整理汇总了PHP中EEM_Base::get_field_containing_related_model_name方法的典型用法代码示例。如果您正苦于以下问题:PHP EEM_Base::get_field_containing_related_model_name方法的具体用法?PHP EEM_Base::get_field_containing_related_model_name怎么用?PHP EEM_Base::get_field_containing_related_model_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EEM_Base的用法示例。


在下文中一共展示了EEM_Base::get_field_containing_related_model_name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _replace_temp_ids_with_mappings

 /**
  * Using the $old_db_to_new_db_mapping array, replaces all the temporary IDs
  * with their mapped real IDs. Eg, if importing from site A to B, the mapping
  * file may indicate that the ID "my_event_id" maps to an actual event ID of 123.
  * So this function searches for any event temp Ids called "my_event_id" and
  * replaces them with 123.
  * Also, if there is no temp ID for the INT foreign keys from another database,
  * replaces them with 0 or the field's default.
  * @param type $model_object_data
  * @param EEM_Base $model
  * @param type $old_db_to_new_db_mapping
  * @param boolean $export_from_site_a_to_b
  * @return array updated model object data with temp IDs removed
  */
 protected function _replace_temp_ids_with_mappings($model_object_data, $model, $old_db_to_new_db_mapping, $export_from_site_a_to_b)
 {
     //if this model object's primary key is in the mapping, replace it
     if ($model->has_primary_key_field() && $model->get_primary_key_field()->is_auto_increment() && isset($old_db_to_new_db_mapping[$model->get_this_model_name()]) && isset($old_db_to_new_db_mapping[$model->get_this_model_name()][$model_object_data[$model->primary_key_name()]])) {
         $model_object_data[$model->primary_key_name()] = $old_db_to_new_db_mapping[$model->get_this_model_name()][$model_object_data[$model->primary_key_name()]];
     }
     try {
         $model_name_field = $model->get_field_containing_related_model_name();
         $models_pointed_to_by_model_name_field = $model_name_field->get_model_names_pointed_to();
     } catch (EE_Error $e) {
         $model_name_field = NULL;
         $models_pointed_to_by_model_name_field = array();
     }
     foreach ($model->field_settings(true) as $field_obj) {
         if ($field_obj instanceof EE_Foreign_Key_Int_Field) {
             $models_pointed_to = $field_obj->get_model_names_pointed_to();
             $found_a_mapping = false;
             foreach ($models_pointed_to as $model_pointed_to_by_fk) {
                 if ($model_name_field) {
                     $value_of_model_name_field = $model_object_data[$model_name_field->get_name()];
                     if ($value_of_model_name_field == $model_pointed_to_by_fk) {
                         $model_object_data[$field_obj->get_name()] = $this->_find_mapping_in($model_object_data[$field_obj->get_name()], $model_pointed_to_by_fk, $old_db_to_new_db_mapping, $export_from_site_a_to_b);
                         $found_a_mapping = true;
                         break;
                     }
                 } else {
                     $model_object_data[$field_obj->get_name()] = $this->_find_mapping_in($model_object_data[$field_obj->get_name()], $model_pointed_to_by_fk, $old_db_to_new_db_mapping, $export_from_site_a_to_b);
                     $found_a_mapping = true;
                 }
                 //once we've found a mapping for this field no need to continue
                 if ($found_a_mapping) {
                     break;
                 }
             }
         } else {
             //it's a string foreign key (which we leave alone, because those are things
             //like country names, which we'd really rather not make 2 USAs etc (we'd actually
             //prefer to just update one)
             //or it's just a regular value that ought to be replaced
         }
     }
     //
     if ($model instanceof EEM_Term_Taxonomy) {
         $model_object_data = $this->_handle_split_term_ids($model_object_data);
     }
     return $model_object_data;
 }
开发者ID:DavidSteinbauer,项目名称:event-espresso-core,代码行数:61,代码来源:EE_Import.class.php


注:本文中的EEM_Base::get_field_containing_related_model_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。