Collections functions
General functions
Render functions
Theme permission functions
User 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 5471 to 5486

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 4th December 2023 18:05 Europe/London time based on the source file dated 21st November 2023 15:25 Europe/London time.