Collections functions
General functions
Render functions
Theme permission functions
Resource functions

get_resource_data_batch()

Description

get_resource_data_batch - get data from resource table for all resource IDs

Parameters

ColumnTypeDefaultDescription
$refs mixed - array of resource IDs

Return

array

Location

include/resource_functions.php lines 434 to 458

Definition

 
function get_resource_data_batch($refs)
    {
    global 
$get_resource_data_cache;
    
truncate_cache_arrays();
    
$resids array_filter($refs,function($id){return (string)(int)$id==(string)$id;});

    if (
count($resids) === 0)
        {
        return array();
        }

    
# Build a string that will return the 'join' columns (not actually joins but cached truncated metadata stored at the resource level)
    
$joins=get_resource_table_joins();
    
$join_fields="";foreach ($joins as $j) {$join_fields.=",field" $j;}

    
$resdata=ps_query("SELECT ref,title,resource_type,has_image,is_transcoding,hit_count,new_hit_count,creation_date,rating,user_rating,user_rating_count,user_rating_total,country,file_extension,preview_extension,image_red,image_green,image_blue,thumb_width,thumb_height,archive,access,colour_key,created_by,file_path,file_modified,file_checksum,request_count,expiry_notification_sent,preview_tweaks,geo_lat,geo_long,mapzoom,disk_usage,disk_usage_last_updated,file_size,preview_attempts,modified,last_verified,integrity_fail,lock_user" $join_fields " FROM resource WHERE ref IN (" ps_param_insert(count($resids)). ")",ps_param_fill($resids,"i"));
    
// Create array with resource ID as index
    
$resource_data = array();
    foreach(
$resdata as $resdatarow)
       {
       
$resource_data[$resdatarow["ref"]] = $resdatarow;
       
$get_resource_data_cache[$resdatarow["ref"]] = $resdatarow;
       }
    return 
$resource_data;
    }

This article was last updated 4th October 2022 10:35 Europe/London time based on the source file dated 30th September 2022 14:20 Europe/London time.