function nodeviewcount_db_count_node_views in Node view count 7
Same name and namespace in other branches
- 7.3 model/nodeviewcount.db.inc \nodeviewcount_db_count_node_views()
- 7.2 model/nodeviewcount.db.inc \nodeviewcount_db_count_node_views()
Count node views.
Parameters
object $node: Node.
object $user: User.
bool $distinct_users: Distinct user or not.
Return value
int Count of node views.
1 call to nodeviewcount_db_count_node_views()
- nodeviewcountcount_count_node_views in includes/
nodeviewcount.api.inc - Count node views.
File
- model/
nodeviewcount.db.inc, line 36
Code
function nodeviewcount_db_count_node_views($node, $user = NULL, $distinct_users = FALSE) {
$query = db_select('nodeviewcount', 'nvc');
$query
->condition('nid', $node->nid, '=');
if ($user) {
$query
->condition('uid', $user->uid, '=');
}
if ($distinct_users) {
$query
->addExpression('COUNT(DISTINCT uid)');
}
else {
$query
->addExpression('COUNT(*)');
}
$result = $query
->execute()
->fetchAll();
return $result;
}