You are here

function _file_resource_index in Services 7.3

Same name and namespace in other branches
  1. 6.3 resources/file_resource.inc \_file_resource_index()

Return an array of optionally paged fids based on a set of criteria.

An example request might look like

http://domain/endpoint/file?fields=fid,filename&parameters[fid]=7&parame...

This would return an array of objects with only fid and filename defined, where fid = 7 and uid = 1.

Parameters

$page: Page number of results to return (in pages of 20).

$fields: The fields you want returned.

$parameters: An array containing fields and values used to build a sql WHERE clause indicating items to retrieve.

$page_size: Integer number of items to be returned.

$options: Additional query options.

Return value

An array of file objects.

See also

_node_resource_index() for more notes

1 string reference to '_file_resource_index'
_file_resource_definition in resources/file_resource.inc
THERE SHOULD BE NO UPDATE!!! Drupal doesn't allow updating or replacing a file in the files table. If you need to, create a new file and remove the old file.

File

resources/file_resource.inc, line 345
File resource.

Code

function _file_resource_index($page, $fields, $parameters, $page_size, $options = array()) {
  $file_select = db_select('file_managed', 't');
  services_resource_build_index_query($file_select, $page, $fields, $parameters, $page_size, 'file', $options);
  $results = services_resource_execute_index_query($file_select);

  // Put together array of matching files to return.
  return services_resource_build_index_list($results, 'file', 'fid');
}