Notifications.php 963 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Giancarlo
  5. * Date: 29/08/2018
  6. * Time: 16:36
  7. */
  8. namespace OpenMind\System;
  9. use DB\SQL\Mapper;
  10. class Notifications extends Mapper
  11. {
  12. /** @var \Base $f3 */
  13. private $f3;
  14. // Used internally
  15. private $initLoad;
  16. public function __construct()
  17. {
  18. global $f3;
  19. $this->f3 = $f3;
  20. parent::__construct($f3->get('DB'), 'notifications');
  21. $this->count = 'count(code)';
  22. }
  23. /**
  24. * Retrieve notifications
  25. *
  26. * @return array|FALSE
  27. */
  28. public function check()
  29. {
  30. if (!$this->initLoad) {
  31. $this->initLoad = true;
  32. $this->load();
  33. }
  34. return $this->dry();
  35. }
  36. /**
  37. * @param int $code of notification to remove from database
  38. */
  39. public function Remove(int $code)
  40. {
  41. $this->reset();
  42. $this->erase(['code=?', $code]);
  43. }
  44. /**
  45. * Truncate all table
  46. */
  47. public function emptyAll()
  48. {
  49. $this->f3->get('DB')->exec('TRUNCATE TABLE notifications');
  50. }
  51. }