Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test 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 477 to 512

Definition

 
function get_resource_data_batch($refs)
{
    global 
$get_resource_data_cache;
    
truncate_cache_arrays();

    
$resids array_values(array_unique(array_filter($refs'is_int_loose')));
    if (
count($resids) === 0) {
        return array();
    }
    
$resids_chunked count($resids) <= SYSTEM_DATABASE_IDS_CHUNK_SIZE
        
? [$resids]
        : 
array_chunk($residsSYSTEM_DATABASE_IDS_CHUNK_SIZE);

    
# 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 = empty($joins) ? '' ',' implode(','array_map(prefix_value('field'), $joins));

    
$resource_data = array();
    foreach (
$resids_chunked as $resids_cnk) {
        
$resdata ps_query(
            
sprintf(
                
'SELECT %s%s FROM `resource` WHERE ref IN (%s)',
                
columns_in('resource'),
                
$join_fields,
                
ps_param_insert(count($resids_cnk))
            ),
            
ps_param_fill($resids_cnk'i')
        );
        foreach (
$resdata as $resdatarow) {
            
$resource_data[$resdatarow["ref"]] = $resdatarow;
            
$get_resource_data_cache[$resdatarow["ref"]] = $resdatarow;
        }
    }

    return 
$resource_data;
}

This article was last updated 17th November 2024 15:05 Europe/London time based on the source file dated 15th November 2024 18:30 Europe/London time.