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

update_resource_keyword_hitcount()

Parameters

ColumnTypeDefaultDescription
$resource
$search

Location

include/resource_functions.php lines 7247 to 7270

Definition

 
function update_resource_keyword_hitcount($resource,$search)
    {
    
# For the specified $resource, increment the hitcount for each matching keyword in $search
    # This is done into a temporary column first (new_hit_count) so existing results are not affected.
    # copy_hitcount_to_live() is then executed at a set interval to make this data live.
    
$keywords=split_keywords($search);
    
$keys=array();
    for (
$n=0;$n<count($keywords);$n++)
        {
        
$keyword=$keywords[$n];
        if (
strpos($keyword,":")!==false)
            {
            
$k=explode(":",$keyword);
            
$keyword=$k[1];
            }
        
$found=resolve_keyword($keyword);
        if (
$found!==false) {$keys[]=resolve_keyword($keyword);}
        }   
    if (
count($keys)>0)
        {
        
// Get all nodes matching these keywords
        
ps_query("update resource_keyword set new_hit_count=new_hit_count+1 where resource=? and keyword in (" ps_param_insert(count($keys)) . ")",array_merge(array("i",$resource),ps_param_fill($keys,"i")),false,-1,true,0);
        }
    }

This article was last updated 28th June 2022 15:05 Europe/London time based on the source file dated 27th June 2022 12:50 Europe/London time.