BxFilesDb.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 Files Files
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /*
  12. * Module database queries
  13. */
  14. class BxFilesDb extends BxBaseModTextDb
  15. {
  16. function __construct(&$oConfig)
  17. {
  18. parent::__construct($oConfig);
  19. }
  20. public function getFileTitle($iFileId)
  21. {
  22. $sQuery = $this->prepare ("SELECT `c`.`title` FROM `" . $this->_oConfig->CNF['TABLE_ENTRIES'] . "` AS `c` INNER JOIN `sys_storage_ghosts` AS `g` ON(`g`.`object` = ? AND `g`.`content_id` = `c`.`id`) WHERE `g`.`id` = ?", $this->_oConfig->CNF['TABLE_FILES'], $iFileId);
  23. return $this->getOne($sQuery);
  24. }
  25. public function updateFileId ($iContentId, $iFileId)
  26. {
  27. $sQuery = $this->prepare ("UPDATE `" . $this->_oConfig->CNF['TABLE_ENTRIES'] . "` SET `file_id` = ?, `data` = '', `data_processed` = 0 WHERE `id` = ?", $iFileId, $iContentId);
  28. return $this->query($sQuery);
  29. }
  30. public function updateFileData ($iContentId, $sData, $iDataProcessed = 1)
  31. {
  32. $sQuery = $this->prepare ("UPDATE `" . $this->_oConfig->CNF['TABLE_ENTRIES'] . "` SET `data` = ?, `data_processed` = ? WHERE `id` = ?", $sData, $iDataProcessed, $iContentId);
  33. return $this->query($sQuery);
  34. }
  35. public function getNotProcessedFiles ($iLimit)
  36. {
  37. $sQuery = $this->prepare ("SELECT * FROM `" . $this->_oConfig->CNF['TABLE_ENTRIES'] . "` WHERE `data_processed` = 0 ORDER BY `added` ASC LIMIT ?", $iLimit);
  38. return $this->getAll($sQuery);
  39. }
  40. }
  41. /** @} */