Back to PhocaDownloadStat class

Method getCountFilePerUser

public static
getCountFilePerUser
(mixed $downloadId)

Method getCountFilePerUser - Source code

public static function getCountFilePerUser($downloadId)
{
    $db = Factory::getDBO();
    $user = Factory::getUser();
    $query = ' SELECT count FROM ' . $db->quoteName('#__phocadownload_user_stat') . ' WHERE ' . $db->quoteName('userid') . ' = ' . $db->Quote((int) $user->id) . ' AND ' . $db->quoteName('fileid') . ' = ' . $db->Quote((int) $downloadId) . ' LIMIT 0, 1';
    $db->setQuery($query);
    $count = $db->loadObject();
    if (isset($count->count)) {
        return (int) $count->count;
    } else {
        return 0;
    }
}