Collections functions
General functions
Node 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 5415 to 5430

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 19th March 2024 07:35 Europe/London time based on the source file dated 15th March 2024 17:00 Europe/London time.