BxDolEmbedQuery.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 UnaCore UNA Core
  7. * @{
  8. */
  9. /**
  10. * Database queries for embed objects.
  11. * @see BxDolEmbed
  12. */
  13. class BxDolEmbedQuery extends BxDolFactoryObjectQuery
  14. {
  15. protected $_sTableData;
  16. static public function getObject($sObject)
  17. {
  18. return parent::getObjectFromTable($sObject, 'sys_objects_embeds', true);
  19. }
  20. static public function getObjects ()
  21. {
  22. return parent::getObjectsFromTable('sys_objects_embeds');
  23. }
  24. public function setParams($aParams)
  25. {
  26. $this->_sTableData = $aParams['table_data'] ?? '';
  27. }
  28. public function getLocal ($sUrl, $sTheme)
  29. {
  30. return $this->getOne("SELECT `data` FROM `" . $this->_sTableData . "` WHERE `url` = :url AND `theme` = :theme", [
  31. 'url' => $sUrl,
  32. 'theme' => $sTheme
  33. ]);
  34. }
  35. public function insertLocal ($sUrl, $sTheme, $sData = '')
  36. {
  37. return (int)$this->query("INSERT INTO `" . $this->_sTableData . "` (`url`, `theme`, `data`, `added`) VALUES (:url, :theme, :data, :added)", [
  38. 'url' => $sUrl,
  39. 'theme' => $sTheme,
  40. 'data' => $sData,
  41. 'added' => time(),
  42. ]) > 0;
  43. }
  44. public function updateLocal ($sUrl, $sTheme, $sData = '')
  45. {
  46. return (int)$this->query("UPDATE `" . $this->_sTableData . "` SET `data` = :data WHERE `url` = :url AND `theme` = :theme", [
  47. 'url' => $sUrl,
  48. 'theme' => $sTheme,
  49. 'data' => $sData
  50. ]) > 0;
  51. }
  52. }
  53. /** @} */