Skip to content

Instantly share code, notes, and snippets.

@hissy
Created April 10, 2016 07:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hissy/d176d659ea407bfffa941e52e2103155 to your computer and use it in GitHub Desktop.
Save hissy/d176d659ea407bfffa941e52e2103155 to your computer and use it in GitHub Desktop.
#concrete5 retrieve file download statistics
<?php
$conn = Database::connection();
$qb = $conn->createQueryBuilder();
$qb->select('*')
->from('DownloadStatistics')
->orderBy('timestamp', 'ASC');
if ($startdate = $_GET['startdate']) {
$qb->andWhere(
$qb->expr()->gt('timestamp', ':startdate')
)->setParameter('startdate', $startdate);
}
if ($enddate = $_GET['enddate']) {
$qb->andWhere(
$qb->expr()->lt('timestamp', ':enddate')
)->setParameter('enddate', $enddate);
}
$results = $qb->execute();
while ($row = $results->fetch()) {
$f = File::getByID($row['fID']);
$fv = $f->getVersion($row['fvID']);
$ui = UserInfo::getByID($row['uID']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment