Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
log.php
1<?php
2namespace Bitrix\Seo\Adv;
3
9
41class LogTable extends Entity\DataManager
42{
43 const TTL = 604800; // one week
44
50 public static function getTableName()
51 {
52 return 'b_seo_adv_log';
53 }
54
60 public static function getMap()
61 {
62 return array(
63 'ID' => array(
64 'data_type' => 'integer',
65 'primary' => true,
66 'autocomplete' => true,
67 ),
68 'ENGINE_ID' => array(
69 'data_type' => 'integer',
70 'required' => true,
71 ),
72 'TIMESTAMP_X' => array(
73 'data_type' => 'datetime',
74 'required' => true,
75 ),
76 'REQUEST_URI' => array(
77 'data_type' => 'string',
78 'required' => true,
79 ),
80 'REQUEST_DATA' => array(
81 'data_type' => 'text',
82 'required' => true,
83 ),
84 'RESPONSE_TIME' => array(
85 'data_type' => 'float',
86 'required' => true,
87 ),
88 'RESPONSE_STATUS' => array(
89 'data_type' => 'integer',
90 'required' => true,
91 ),
92 'RESPONSE_DATA' => array(
93 'data_type' => 'text',
94 'required' => true,
95 ),
96 );
97 }
98
99 public static function onBeforeAdd(Entity\Event $event)
100 {
101 $result = new Entity\EventResult();
102 $result->modifyFields(array("TIMESTAMP_X" => new DateTime()));
103 return $result;
104 }
105
106 public static function clean()
107 {
108 $connection = Application::getConnection();
109 $sqlHelper = $connection->getSqlHelper();
110
111 $tableName = static::getTableName();
112 $deleteBorder = $sqlHelper->addSecondsToDateTime(
113 -static::TTL,
114 $sqlHelper->getCurrentDateTimeFunction()
115 );
116
117 $connection->queryExecute("DELETE FROM {$tableName} WHERE TIMESTAMP_X < {$deleteBorder}");
118
119 return __CLASS__."::clean();";
120 }
121}
static getConnection($name="")
static onBeforeAdd(Entity\Event $event)
Definition log.php:99
static getTableName()
Definition log.php:50