- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/exchange/internals/exchangelog.php
- Класс: BitrixSaleExchangeInternalsExchangeLogTable
- Вызов: ExchangeLogTable::deleteOldRecords
static function deleteOldRecords($direction, $provider, $interval)
{
$tableName = static::getTableName();
if ($direction == '')
throw new MainArgumentOutOfRangeException("$direction");
if ($provider == '')
throw new MainArgumentOutOfRangeException("$provider");
$r = ExchangeLogTable::getList(array(
'select' => array(
new MainEntityExpressionField('MAX_DATE_INSERT', 'MAX(%s)', array('DATE_INSERT'))
),
'filter' => array(
'=DIRECTION'=>$direction,
'=PROVIDER'=>$provider
)
));
if ($loggingRecord = $r->fetch())
{
if($loggingRecord['MAX_DATE_INSERT'] <> '')
{
$maxDateInsert = $loggingRecord['MAX_DATE_INSERT'];
$date = new MainTypeDateTime($maxDateInsert);
$connection = MainApplication::getConnection();
$connection->queryExecute("delete from {$tableName} where DATE_INSERT < DATE_SUB('{$date->format("Y-m-d")}', INTERVAL {$interval} DAY) and DIRECTION='{$direction}' and PROVIDER='{$provider}'");
}
}
}