felladrin / online-visitors-counter

Real-time online visitors counter using Ajax, PHP PDO and SQLite.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Perform a query delete on NULL last_activity and id suggestion

alecos71 opened this issue · comments

My patch for fixing the NULL values issue is the following:

$count = $db->query('SELECT COUNT() AS visitors, COUNT(DISTINCT page_url) AS pages FROM online WHERE last_activity IS NOT NULL AND id IS NOT NULL')->fetch(PDO::FETCH_ASSOC);

Would be better perform a delete query on NULL values of last_activity and id?

The query select is only a simple patch e doesn't provide a true solution...

What do you think about?

online.zip

I attach here a sqlite db which is affected by this bug... and add 2 screenshot showing the issue...

Online 01

Online 02
.

I tried to delete the NULL values but for some strange reason doesn't work. Here is an example:

$deleteNull = $db->prepare('DELETE FROM online WHERE last_activity IS NULL AND id IS NULL');
$deleteNull->execute();

The query is executed but the NULL values still are there.

Some suggestion?

For manipulating sqlite database I always use https://sqlitebrowser.org/ available for a large hardware platform. At the moment it's the best for viewing database structure and inspecting NULL values in database.

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.