BxStrmDb.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup Stream Stream
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /*
  12. * Module database queries
  13. */
  14. class BxStrmDb extends BxBaseModTextDb
  15. {
  16. function __construct(&$oConfig)
  17. {
  18. parent::__construct($oConfig);
  19. }
  20. public function getNewRecordingId($iContentId)
  21. {
  22. if (!$this->query("INSERT INTO `bx_stream_recordings_seq` SET `content_id` = :content_id, `added` = :ts", ['content_id' => $iContentId, 'ts' => time()]))
  23. return false;
  24. return $this->lastId();
  25. }
  26. public function getRecordingId($iContentId)
  27. {
  28. return $this->getOne("SELECT `id` FROM `bx_stream_recordings_seq` WHERE `content_id` = :content_id ORDER BY `id` DESC", ['content_id' => $iContentId]);
  29. }
  30. public function getPendingRecordings ($iLimit = 2)
  31. {
  32. return $this->getAll("SELECT * FROM `bx_stream_recordings_seq` ORDER BY `id` ASC LIMIT " . (int)$iLimit);
  33. }
  34. public function updateRecording($iRecordingId, $aValues = [])
  35. {
  36. $sValues = $this->arrayToSQL($aValues);
  37. return $this->getOne("UPDATE `bx_stream_recordings_seq` SET $sValues WHERE `id` = :id", ['id' => $iRecordingId]);
  38. }
  39. public function deleteRecording($iRecordingId)
  40. {
  41. return $this->query("DELETE FROM `bx_stream_recordings_seq` WHERE `id` = :id", ['id' => $iRecordingId]);
  42. }
  43. }
  44. /** @} */