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