BxDolKeyQuery.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup DolphinCore Dolphin Core
  7. * @{
  8. */
  9. bx_import('BxDolDb');
  10. /**
  11. * Database queries for BxDolKey object.
  12. * @see BxDolKey
  13. */
  14. class BxDolKeyQuery extends BxDolDb
  15. {
  16. public function __construct()
  17. {
  18. parent::__construct();
  19. }
  20. public function insert ($sKey, $sData, $iExpire)
  21. {
  22. $sQuery = $this->prepare("INSERT INTO `sys_keys` SET `key` = ?, `data` = ?, `expire` = ?", $sKey, $sData, time() + $iExpire);
  23. return $this->query($sQuery);
  24. }
  25. public function remove ($sKey)
  26. {
  27. $sQuery = $this->prepare("DELETE FROM `sys_keys` WHERE `key` = ?", $sKey);
  28. return $this->query($sQuery);
  29. }
  30. public function get ($sKey)
  31. {
  32. $sQuery = $this->prepare("SELECT `key` FROM `sys_keys` WHERE `key` = ?", $sKey);
  33. return $this->getOne($sQuery);
  34. }
  35. public function getData ($sKey)
  36. {
  37. $sQuery = $this->prepare("SELECT `data` FROM `sys_keys` WHERE `key` = ?", $sKey);
  38. return $this->getOne($sQuery);
  39. }
  40. public function prune ()
  41. {
  42. $sQuery = $this->prepare("DELETE FROM `sys_keys` WHERE `expire` < ?", time());
  43. return $this->query($sQuery);
  44. }
  45. }
  46. /** @} */