BxStrmDb.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. $CNF = &$this->_oConfig->CNF;
  33. return $this->getAll("SELECT `r`.* FROM `bx_stream_recordings_seq` AS `r` INNER JOIN `{$CNF['TABLE_ENTRIES']}` AS `c` ON (`r`.`content_id` = `c`.`id` AND `c`.`status` = 'awaiting' AND `r`.`status` = 'pending') ORDER BY `r`.`id` ASC LIMIT " . (int)$iLimit);
  34. }
  35. public function updateRecording($iRecordingId, $aValues = [])
  36. {
  37. $sValues = $this->arrayToSQL($aValues);
  38. return $this->getOne("UPDATE `bx_stream_recordings_seq` SET $sValues WHERE `id` = :id", ['id' => $iRecordingId]);
  39. }
  40. public function deleteRecording($iRecordingId)
  41. {
  42. return $this->query("DELETE FROM `bx_stream_recordings_seq` WHERE `id` = :id", ['id' => $iRecordingId]);
  43. }
  44. }
  45. /** @} */