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


PHP EEM_Base::get_all_wpdb_results方法代码示例

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


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

示例1: get_entity_from_model

 /**
  * Gets the one model object with the specified id for the specified model
  * @param \EEM_Base $model
  * @param \WP_REST_Request $request
  * @return array
  */
 public function get_entity_from_model($model, $request)
 {
     $query_params = array(array($model->primary_key_name() => $request->get_param('id')), 'limit' => 1);
     if ($model instanceof \EEM_Soft_Delete_Base) {
         $query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params);
     }
     $restricted_query_params = $query_params;
     $restricted_query_params['caps'] = $this->validate_context($request->get_param('caps'));
     $this->_set_debug_info('model query params', $restricted_query_params);
     $model_rows = $model->get_all_wpdb_results($restricted_query_params);
     if (!empty($model_rows)) {
         return $this->create_entity_from_wpdb_result($model, array_shift($model_rows), $request->get_param('include'), $this->validate_context($request->get_param('caps')));
     } else {
         //ok let's test to see if we WOULD have found it, had we not had restrictions from missing capabilities
         $lowercase_model_name = strtolower($model->get_this_model_name());
         $model_rows_found_sans_restrictions = $model->get_all_wpdb_results($query_params);
         if (!empty($model_rows_found_sans_restrictions)) {
             //you got shafted- it existed but we didn't want to tell you!
             return new \WP_Error('rest_user_cannot_read', sprintf(__('Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso'), strtolower($model->get_this_model_name()), Capabilities::get_missing_permissions_string($model, $this->validate_context($request->get_param('caps')))), array('status' => 403));
         } else {
             //it's not you. It just doesn't exist
             return new \WP_Error(sprintf('rest_%s_invalid_id', $lowercase_model_name), sprintf(__('Invalid %s ID.', 'event_espresso'), $lowercase_model_name), array('status' => 404));
         }
     }
 }
开发者ID:adrianjonmiller,项目名称:hearts-being-healed,代码行数:31,代码来源:Read.php


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