Collections functions
General functions
Render functions
Theme permission functions
Resource functions

clear_resource_data()

Parameters

ColumnTypeDefaultDescription
$resource

Location

include/resource_functions.php lines 3454 to 3476

Definition

 
function clear_resource_data($resource)
    {
    
# Clears stored data for a resource.
    
ps_query("delete from resource_data where resource=?",array("i",$resource));
    
ps_query("delete from resource_dimensions where resource=?",array("i",$resource));
    
ps_query("delete from resource_keyword where resource=?",array("i",$resource));
    
ps_query("delete from resource_related where resource=? or related=?",array("i",$resource,"i",$resource));
    
delete_all_resource_nodes($resource); 
    
    
// Clear all 'joined' fields
    
$joins=get_resource_table_joins();
    if(
count($joins) > 0)
        {
        
$joins_sql "";
        foreach (
$joins as $join)
            {
            
$joins_sql .= (($joins_sql!="")?",":"") . "field" escape_check($join) . "=NULL";
            }
        
ps_query("UPDATE resource SET $joins_sql WHERE ref=?",array("i",$resource)); // $joins_sql does not contain user provided input and is safe
        
}
        
    return 
true;
    }

This article was last updated 26th June 2022 02:05 Europe/London time based on the source file dated 24th June 2022 09:15 Europe/London time.