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 4637 to 4655

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)
        {
        
delete_collection($old_collection);
        
$deletioncount++;
        }
    return 
$deletioncount;
    }

This article was last updated 17th May 2021 22:05 Europe/London time based on the source file dated 10th May 2021 09:15 Europe/London time.