Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict db queries ? #20

Open
katkad opened this issue Aug 26, 2014 · 2 comments
Open

Restrict db queries ? #20

katkad opened this issue Aug 26, 2014 · 2 comments

Comments

@katkad
Copy link
Contributor

katkad commented Aug 26, 2014

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

@ikoniaris
Copy link
Owner

Hi @katkad, can you share any code perhaps?

@katkad
Copy link
Contributor Author

katkad commented Sep 1, 2014

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 ";

@ikoniaris ikoniaris self-assigned this Jan 31, 2015
@ikoniaris ikoniaris removed their assignment Jul 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants