本文整理汇总了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;
}
示例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;
}