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


PHP EEM_Base::get_primary_key_field方法代码示例

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


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

示例1: _get_entity_links

 /**
 * Gets links we want to add to the response
 *
 *@global \WP_REST_Server $wp_rest_server
 * @param \EEM_Base $model
 * @param array $db_row
 * @param array $entity_array
 * @return array the _links item in the entity
 */
 protected function _get_entity_links($model, $db_row, $entity_array)
 {
     //add basic links
     $links = array('self' => array(array('href' => $this->get_versioned_link_to(\EEH_Inflector::pluralize_and_lower($model->get_this_model_name()) . '/' . $entity_array[$model->primary_key_name()]))), 'collection' => array(array('href' => $this->get_versioned_link_to(\EEH_Inflector::pluralize_and_lower($model->get_this_model_name())))));
     //add link to the wp core endpoint, if wp api is active
     global $wp_rest_server;
     if ($model instanceof \EEM_CPT_Base && $wp_rest_server instanceof \WP_REST_Server && $wp_rest_server->get_route_options('/wp/v2/posts')) {
         $links[\EED_Core_Rest_Api::ee_api_link_namespace . 'self_wp_post'] = array(array('href' => rest_url('/wp/v2/posts/' . $db_row[$model->get_primary_key_field()->get_qualified_column()]), 'single' => true));
     }
     //add links to related models
     foreach ($this->get_model_version_info()->relation_settings($model) as $relation_name => $relation_obj) {
         $related_model_part = Read::get_related_entity_name($relation_name, $relation_obj);
         $links[\EED_Core_Rest_Api::ee_api_link_namespace . $related_model_part] = array(array('href' => $this->get_versioned_link_to(\EEH_Inflector::pluralize_and_lower($model->get_this_model_name()) . '/' . $entity_array[$model->primary_key_name()] . '/' . $related_model_part), 'single' => $relation_obj instanceof \EE_Belongs_To_Relation ? true : false));
     }
     return $links;
 }
开发者ID:aaronfrey,项目名称:PepperLillie-GSP,代码行数:25,代码来源:Read.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::get_primary_key_field方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。