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 ?
|
Mar '17 |
3 |
248 |
0 |
Just call count()
method on your model object?
https://docs.phalconphp.com/en/latest/reference/models.html#generating-calculations
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.
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