Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
analyticstable.php
1<?php
2
4
11
31class AnalyticsTable extends Main\Entity\DataManager
32{
36 public static function getTableName()
37 {
38 return 'b_sale_analytics';
39 }
40
44 public static function getMap()
45 {
46 return [
47 (new IntegerField('ID'))
48 ->configureAutocomplete()
49 ->configurePrimary(),
50 (new StringField('CODE'))
51 ->configureRequired()
52 ->configureSize(255),
53 (new DatetimeField('CREATED_AT'))
54 ->configureRequired()
55 ->configureDefaultValue(static function() {
56 return new DateTime();
57 }),
58 (new ArrayField('PAYLOAD'))
59 ->configureSerializationPhp()
60 ->configureUnserializeCallback(function ($value) {
61 return unserialize(
62 $value,
63 ['allowed_classes' => false]
64 );
65 }),
66 ];
67 }
68
73 public static function deleteByDate(Main\Type\DateTime $dateTo): Main\DB\Result
74 {
75 $connection = Main\Application::getConnection();
76 $helper = $connection->getSqlHelper();
77
78 return $connection->query(sprintf(
79 'DELETE FROM %s WHERE CREATED_AT <= %s',
80 $helper->quote(AnalyticsTable::getTableName()),
81 $helper->convertToDbDateTime($dateTo)
82 ));
83 }
84
92 public static function deleteByCodeAndDate(string $providerCode, Main\Type\DateTime $dateTo): Main\DB\Result
93 {
94 $connection = Main\Application::getConnection();
95 $helper = $connection->getSqlHelper();
96
97 return $connection->query(sprintf(
98 'DELETE FROM %s WHERE CODE = %s AND CREATED_AT <= %s',
99 $helper->quote(AnalyticsTable::getTableName()),
100 $helper->convertToDbString($providerCode),
101 $helper->convertToDbDateTime($dateTo)
102 ));
103 }
104}
static deleteByCodeAndDate(string $providerCode, Main\Type\DateTime $dateTo)
static deleteByDate(Main\Type\DateTime $dateTo)