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


PHP EEM_Base::insert方法代码示例

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


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

示例1: insert

 /**
  * Overrides the parent to also make sure term-taxonomy counts are up-to-date after
  * inserting
  * @param array $field_n_values @see EEM_Base::insert
  * @return boolean
  */
 public function insert($field_n_values)
 {
     $return = parent::insert($field_n_values);
     if (isset($field_n_values['term_taxonomy_id'])) {
         $this->update_term_taxonomy_counts($field_n_values['term_taxonomy_id']);
     }
     return $return;
 }
开发者ID:robert-osborne,项目名称:event-espresso-core-1,代码行数:14,代码来源:EEM_Term_Relationship.model.php

示例2: _insert_from_data_array

 /**
  *
  * @param type $id_in_csv
  * @param type $model_object_data
  * @param EEM_Base $model
  * @param type $old_db_to_new_db_mapping
  * @return array updated $old_db_to_new_db_mapping
  */
 protected function _insert_from_data_array($id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping)
 {
     //remove the primary key, if there is one (we don't want it for inserts OR updates)
     //we'll put it back in if we need it
     if ($model->has_primary_key_field() && $model->get_primary_key_field()->is_auto_increment()) {
         $effective_id = $model_object_data[$model->primary_key_name()];
         unset($model_object_data[$model->primary_key_name()]);
     } else {
         $effective_id = $model->get_index_primary_key_string($model_object_data);
     }
     //the model takes care of validating the CSV's input
     try {
         $new_id = $model->insert($model_object_data);
         if ($new_id) {
             $old_db_to_new_db_mapping[$model->get_this_model_name()][$id_in_csv] = $new_id;
             $this->_total_inserts++;
             EE_Error::add_success(sprintf(__("Successfully added new %s (with id %s) with csv data %s", "event_espresso"), $model->get_this_model_name(), $new_id, implode(",", $model_object_data)));
         } else {
             $this->_total_insert_errors++;
             //put the ID used back in there for the error message
             if ($model->has_primary_key_field()) {
                 $model_object_data[$model->primary_key_name()] = $effective_id;
             }
             EE_Error::add_error(sprintf(__("Could not insert new %s with the csv data: %s", "event_espresso"), $model->get_this_model_name(), http_build_query($model_object_data)), __FILE__, __FUNCTION__, __LINE__);
         }
     } catch (EE_Error $e) {
         $this->_total_insert_errors++;
         if ($model->has_primary_key_field()) {
             $model_object_data[$model->primary_key_name()] = $effective_id;
         }
         EE_Error::add_error(sprintf(__("Could not insert new %s with the csv data: %s because %s", "event_espresso"), $model->get_this_model_name(), implode(",", $model_object_data), $e->getMessage()), __FILE__, __FUNCTION__, __LINE__);
     }
     return $old_db_to_new_db_mapping;
 }
开发者ID:DavidSteinbauer,项目名称:event-espresso-core,代码行数:42,代码来源:EE_Import.class.php


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