1: | <?php |
2: | |
3: | |
4: | |
5: | |
6: | |
7: | |
8: | namespace Aurora\Modules\MailScheduledMessages\Storages\Db; |
9: | |
10: | |
11: | |
12: | |
13: | |
14: | |
15: | class CommandCreator extends \Aurora\System\Db\AbstractCommandCreator |
16: | { |
17: | |
18: | |
19: | |
20: | public function getMessagesForSend($iTimestamp) |
21: | { |
22: | $sSql = "SELECT * FROM %smail_scheduled_messages WHERE schedule_timestamp < %d ORDER BY schedule_timestamp"; |
23: | |
24: | return sprintf($sSql, $this->prefix(), $iTimestamp); |
25: | } |
26: | |
27: | |
28: | |
29: | |
30: | |
31: | |
32: | |
33: | |
34: | |
35: | public function addMessage($iAccountID, $sFolderFullName, $sMessageUid, $iScheduledTimestamp) |
36: | { |
37: | $sSql = 'INSERT INTO %smail_scheduled_messages ( account_id, folder_full_name, message_uid, schedule_timestamp ) VALUES ( %d, %s, %s, %d )'; |
38: | |
39: | return sprintf($sSql, $this->prefix(), $iAccountID, $this->escapeString($sFolderFullName), $this->escapeString($sMessageUid), $iScheduledTimestamp); |
40: | } |
41: | |
42: | |
43: | |
44: | |
45: | |
46: | |
47: | |
48: | |
49: | |
50: | public function updateMessageScheduleTimestamp($iAccountID, $sFolderFullName, $sMessageUid, $iScheduledTimestamp) |
51: | { |
52: | $sSql = 'UPDATE %smail_scheduled_messages SET schedule_timestamp = %d WHERE account_id = %d AND folder_full_name = %s AND message_uid = %s'; |
53: | |
54: | return sprintf($sSql, $this->prefix(), $iScheduledTimestamp, $iAccountID, $this->escapeString($sFolderFullName), $this->escapeString($sMessageUid)); |
55: | } |
56: | |
57: | public function getMessage($iAccountID, $sFolderFullName, $sMessageUid) |
58: | { |
59: | $sSql = 'SELECT * FROM %smail_scheduled_messages WHERE account_id = %d AND folder_full_name = %s AND message_uid = %s'; |
60: | |
61: | return sprintf($sSql, $this->prefix(), $iAccountID, $this->escapeString($sFolderFullName), $this->escapeString($sMessageUid)); |
62: | } |
63: | |
64: | |
65: | |
66: | |
67: | |
68: | |
69: | public function removeMessage($iAccountID, $sFolderFullName, $sMessageUid) |
70: | { |
71: | $sSql = 'DELETE FROM %smail_scheduled_messages WHERE account_id = %d AND folder_full_name = %s AND message_uid = %s'; |
72: | |
73: | return sprintf($sSql, $this->prefix(), $iAccountID, $this->escapeString($sFolderFullName), $this->escapeString($sMessageUid)); |
74: | } |
75: | } |
76: | |