Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource 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.