Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
synchronizerlog.php
1<?php
2
3
5
6
8use Bitrix\Main\Entity\DataManager;
9use Bitrix\Main\Entity\ExpressionField;
13
31{
32 public static function getTableName()
33 {
34 return 'b_sale_synchronizer_log';
35 }
36
37 public static function getMap()
38 {
39 return array(
40 'ID' => array(
41 'data_type' => 'integer',
42 'primary' => true,
43 'autocomplete' => true
44 ),
45 'MESSAGE_ID' => array(
46 'data_type' => 'text'
47 ),
48 'MESSAGE' => array(
49 'data_type' => 'text'
50 ),
51 'DATE_INSERT' => array(
52 'data_type' => 'datetime',
53 'require' => true,
54 'default_value' => function(){return new \Bitrix\Main\Type\DateTime();}
55 )
56 );
57 }
58
62 public static function deleteOldRecords($direction)
63 {
64 $tableName = static::getTableName();
65
67 'select' => array(
68 new ExpressionField('MAX_DATE_INSERT', 'MAX(%s)', array('DATE_INSERT'))
69 )
70 ));
71
72 if ($loggingRecord = $r->fetch())
73 {
74 if($loggingRecord['MAX_DATE_INSERT'] <> '')
75 {
76 $maxDateInsert = $loggingRecord['MAX_DATE_INSERT'];
77 $date = new DateTime($maxDateInsert);
78 $interval = LoggerDiag::getInterval();
79 $connection = Application::getConnection();
80 $connection->queryExecute("delete from {$tableName} where DATE_INSERT < DATE_SUB('{$date->format("Y-m-d")}', INTERVAL {$interval} DAY)");
81 }
82 }
83 }
84}
static getConnection($name="")
static getList(array $parameters=array())