BxDolEmailQueueQuery.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 BxDolEmailQueue object.
  11. * @see BxDolEmailQueue
  12. */
  13. class BxDolEmailQueueQuery extends BxDolDb
  14. {
  15. protected $_sTable;
  16. public function __construct()
  17. {
  18. parent::__construct();
  19. $this->_sTable = 'sys_email_queue';
  20. }
  21. public function getItems($aParams = array())
  22. {
  23. $aMethod = array('name' => 'getAll', 'params' => array(0 => 'query'));
  24. $sSelectClause = '*';
  25. $sWhereClause = '';
  26. $sLimitClause = isset($aParams['start']) && !empty($aParams['per_page']) ? "LIMIT " . $aParams['start'] . ", " . $aParams['per_page'] : "";
  27. if(!empty($aParams['type']))
  28. switch($aParams['type']) {
  29. case 'to_send':
  30. $aMethod['name'] = 'getAllWithKey';
  31. $aMethod['params'][1] = 0;
  32. $aMethod['params'][2] = array();
  33. $aMethod['params'][3] = PDO::FETCH_NUM;
  34. break;
  35. }
  36. $aMethod['params'][0] = "SELECT " . $sSelectClause . " FROM `" . $this->_sTable . "` WHERE 1 " . $sWhereClause . $sLimitClause;
  37. return call_user_func_array(array($this, $aMethod['name']), $aMethod['params']);
  38. }
  39. public function insertItem($aValues)
  40. {
  41. if(empty($aValues) || !is_array($aValues))
  42. return false;
  43. return $this->query("INSERT INTO `" . $this->_sTable . "` SET " . $this->arrayToSQL($aValues));
  44. }
  45. public function updateItem($aValues, $aWhere)
  46. {
  47. if(empty($aValues) || !is_array($aValues) || empty($aWhere) || !is_array($aWhere))
  48. return false;
  49. return (int)$this->query("UPDATE `" . $this->_sTable . "` SET " . $this->arrayToSQL($aValues) . " WHERE " . $this->arrayToSQL($aWhere, ' AND ')) > 0;
  50. }
  51. public function deleteItem($mixedId)
  52. {
  53. if(!is_array($mixedId))
  54. $mixedId = array($mixedId);
  55. return (int)$this->query("DELETE FROM `" . $this->_sTable . "` WHERE `id` IN (" . $this->implode_escape($mixedId) . ")") > 0;
  56. }
  57. }
  58. /** @} */