Counts how many messages is stored in the given table.
a DB
name of the table
where to store the resulting count
0 on success, -1 on error