Collections functions
Encryption functions
General functions
Theme permission functions
Resource functions

update_resource_keyword_hitcount()

Parameters

ColumnTypeDefaultDescription
$resource
$search

Location

include/resource_functions.php lines 6744 to 6769

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
        
$nodes get_nodes_from_keywords($keys);
        
update_resource_node_hitcount($resource,$nodes);
        
sql_query("update resource_keyword set new_hit_count=new_hit_count+1 where resource='$resource' and keyword in (" join(",",$keys) . ")",false,-1,true,0);
        }
    }

This article was last updated 12th July 2020 01:05 Europe/London time based on the source file dated 10th July 2020 16:06 Europe/London time.