GetAbandonedUploads.class.php 1.1 KB

12345678910111213141516171819202122232425262728
  1. <?php
  2. class GetAbandonedUploads {
  3. public function get() {
  4. $userId = $_SESSION['user_id'];
  5. $data['abandoned_uploads'] = array();
  6. $sql = "select distinct project_id, uploadtime as upload_timestamp, display_name as project_name from upload_logs join projects on upload_logs.project_id = projects.rowid WHERE user_id = :user_id;";
  7. $db = SqliteDatabase::getSingleton();
  8. $preparedQuery = $db->prepare($sql);
  9. $preparedQuery->bindValue(':user_id', $userId);
  10. $result = $preparedQuery->execute();
  11. $incompleteUploads = array();
  12. while($row = $result->fetchArray(SQLITE3_ASSOC)) {
  13. //$row['upload_timestamp'] = date("Y/m/d H:i", $row['upload_timestamp']);
  14. $sql = "SELECT count(*) as count FROM upload_logs where user_id = :user_id AND project_id = :project_id";
  15. $preparedQuery = $db->prepare($sql);
  16. $preparedQuery->bindValue(':user_id', $userId);
  17. $preparedQuery->bindValue(':project_id', $row['project_id']);
  18. $countResult = $preparedQuery->execute();
  19. $count = $countResult->fetchArray(SQLITE3_ASSOC)['count'];
  20. $row['count'] = $count;
  21. $incompleteUploads[] = $row;
  22. }
  23. return $incompleteUploads;
  24. }
  25. }