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

search_add_annotation_count()

Description

Add annotation count to a search result set

Parameters

ColumnTypeDefaultDescription
&$result
$items array Array of search results returned by do_search()

Location

include/annotation_functions.php lines 543 to 556

Definition

 
function search_add_annotation_count(&$result)
{
    
$annotations ps_query(
        
"SELECT resource, count(*) as annocount
           FROM annotation
          WHERE resource IN (" 
ps_param_insert(count($result)) . ")
       GROUP BY resource"
,
        
ps_param_fill(array_column($result"ref"), "i")
    );
    
$res_annotations array_column($annotations"annocount""resource");
    foreach (
$result as &$resource) {
        
$resource["annotation_count"] = $res_annotations[$resource["ref"]] ?? 0;
    }
}

This article was last updated 29th January 2025 20:35 Europe/London time based on the source file dated 27th January 2025 17:10 Europe/London time.