kippo-graph icon indicating copy to clipboard operation
kippo-graph copied to clipboard

Restrict db queries ?

Open katkad opened this issue 10 years ago • 2 comments

hello,

have you thought about restricting db queries to X weeks ?

I have kippo running for about 2 years, so I'd like more current statisticks.

the safest way would be to use PDO http://php.net/manual/en/book.pdo.php and bindParam, but you'd have to rewrite most of db things in kippo-graph

I just use new variable from config.php in db_query string, but this is not the best approach but it works.

I also use indexes on timestamp columns in db

another questions is, what the default value for this would be

katkad avatar Aug 26 '14 14:08 katkad

Hi @katkad, can you share any code perhaps?

ikoniaris avatar Aug 29 '14 17:08 ikoniaris

in config.php: define('LAST_WEEKS', '4');

then query looks like this: $db_query = 'SELECT ip, COUNT(ip) ' . "FROM sessions " . "WHERE starttime > DATE_SUB(now(), interval ".LAST_WEEKS." week) " . "GROUP BY ip " . "ORDER BY COUNT(ip) DESC " . "LIMIT 15 ";

katkad avatar Sep 01 '14 11:09 katkad