Collections functions
General functions
Render functions
Theme permission 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 5298 to 5313

Definition

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

    
$deletioncount 0;
    
$old_collections=ps_array("SELECT ref value FROM collection WHERE user = ? AND created < DATE_SUB(NOW(), INTERVAL ? DAY) AND `type` = " COLLECTION_TYPE_STANDARD, array("i",$userref,"i",$days), 0);
    foreach(
$old_collections as $old_collection)
        {
        
delete_collection($old_collection);
        
$deletioncount++;
        }
    return 
$deletioncount;
    }

This article was last updated 2nd October 2022 03:05 Europe/London time based on the source file dated 22nd September 2022 11:00 Europe/London time.