Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

delete_old_collections()

Description

Delete all collections that are not in use e.g. session collections for the anonymous user. Will not affect collections that are public.

Parameters

ColumnTypeDefaultDescription
$userref integer 0 - ID of user to delete collections for
$days integer 30 - minimum age of collections to delete in days

Return

integer - number of collections deleted

Location

include/collections_functions.php lines 4333 to 4352

Definition

 
function delete_old_collections($userref=0$days=30)
    {
    if(
$userref==|| !is_numeric($userref))
        {
        return 
0;
        }

    
$userref escape_check($userref);
    
$days escape_check($days);

    
$deletioncount 0;
    
$old_collections=sql_array("SELECT ref value FROM collection WHERE user ='{$userref}' AND created < DATE_SUB(NOW(), INTERVAL '{$days}' DAY) AND `type` = " COLLECTION_TYPE_STANDARD0);
    foreach(
$old_collections as $old_collection)
        {
        
sql_query("DELETE FROM collection_resource WHERE collection='" $old_collection "'");
        
sql_query("DELETE FROM collection WHERE ref='" $old_collection "'");
        
$deletioncount++;
        }
    return 
$deletioncount;
    }

This article was last updated 30th November 2020 16:05 Europe/London time based on the source file dated 25th November 2020 10:35 Europe/London time.