We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Count where not defined

I have two tables

Notifications Notifications_seen

if notifcation is seen a row is added to notification_seen

But I need to count how many notifcations that's not seen. How do I do this? Any suggestions ?

But how? Where not exist ?

Hmmm why not just have column for that in the notifications table and remove the second table? Is_seen(tinyint) or seen_at (timestamp) ?

If you really want to have two tables look here.

edited Mar '17

Hmmm why not just have column for that in the notifications table and remove the second table? Is_seen(tinyint) or seen_at (timestamp) ?

If you really want to have two tables look here.

I think it's the best option.

is_seen -> default value is 0, when seen it's become 1.

So every seen -> count all where is_seen = 1

every unseen -> count all where is_seen = 0