Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. public static function canShowFieldToday($fieldId, $userId, $submissionInterval)
  2. {
  3. $date = date("d.m.Y", $submissionInterval);
  4. list($day, $month, $year) = explode(".", $date);
  5.  
  6. $sql = DB::query()
  7. ->select("e.entryDate")
  8. ->from("entries", "e")
  9. ->join("e", "userInput", "ui", "ui.entryId = e.entryId")
  10. ->where("ui.fieldId = ?")
  11. ->andWhere("e.userId = ?")
  12. ->andWhere("e.entryDate > ?")
  13. ->setMaxResults(1)
  14. ->getSQL();
  15.  
  16. $stmt = DB::prepare($sql);
  17. $stmt->bindValue(1, $fieldId);
  18. $stmt->bindValue(2, $userId);
  19. $stmt->bindValue(3, time() - mktime(0, 0, 0, $month, $day, $year));
  20. $stmt->execute();
  21. $counter = $stmt->rowCount();
  22. $stmt->closeCursor();
  23.  
  24. return $counter == 1;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement