Changeset 6179


Ignore:
Timestamp:
May 14, 2010, 7:57:00 AM (14 years ago)
Author:
vdigital
Message:

New: SQLite support.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/History_cleanup/main.inc.php

    r6139 r6179  
    22/*
    33Plugin Name: History cleanup
    4 Version: 2.1.a
     4Version: 2.1.b
    55Description: A background process which cleans your history table on regular basis
    66Plugin URI: http://piwigo.org/ext/extension_view.php?eid=392
     
    1717                    : array( 'each' => 30, 'remove' => 90 ); # DAYs
    1818                $latest = strtotime('-' . $w['each'] . ' days');
     19                $limit = date ('Y-m-d',strtotime('-' . $w['remove'] . ' days'));
    1920                $previous = pwg_get_session_var('history_check', $latest);
    2021                if ( $previous <= $latest ) {
    2122                        $q = '
    2223                        DELETE FROM  ' . HISTORY_TABLE . '
    23                          WHERE date < DATE_SUB(NOW(), INTERVAL ' . $w['remove'] . '  DAY)
     24                         WHERE date < ' . $limit . '
    2425                          AND summarized = "true";';
    25 
    2626                        $r = pwg_query($q); 
    2727                        if($r)
    2828                        {
    29                           if (defined('DB_ENGINE') and DB_ENGINE == 'PostgreSQL')
    30                                $q = 'VACUUM FULL '.HISTORY_TABLE;
    31                           else $q = 'OPTIMIZE TABLE '.HISTORY_TABLE;
    32                           $r=pwg_query($q);
     29                                if (!defined('DB_ENGINE') ) define('DB_ENGINE', 'MySQL');
     30                                switch (DB_ENGINE) {
     31                                        case 'PostgreSQL':
     32                                                $q = 'VACUUM FULL '.HISTORY_TABLE.';';
     33                                                break;
     34                                        case 'MySQL':
     35                                                $q = 'OPTIMIZE TABLE '.HISTORY_TABLE.';';
     36                                                break;
     37                                        default:
     38                                           $q = 'VACUUM;';
     39                                }
     40                                $r=pwg_query($q);
    3341                        }
    3442                        pwg_set_session_var('history_check', strtotime("now"));
Note: See TracChangeset for help on using the changeset viewer.