kippo-graph
kippo-graph copied to clipboard
Restrict db queries ?
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
Hi @katkad, can you share any code perhaps?
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 ";