项目作者: lamoda

项目描述 :
Clear old data from different storages
高级语言: PHP
项目地址: git://github.com/lamoda/cleaner.git
创建时间: 2019-02-07T12:13:54Z
项目社区:https://github.com/lamoda/cleaner

开源协议:MIT License

下载


Lamoda cleaner

Build Status
Scrutinizer Code Quality
Code Coverage
Build Status

Library that provides classes to clear old data from different storages, firstly from databases.

Installation

  1. Install library with composer:
    1. composer require lamoda/cleaner

Standalone usage

Example of DoctrineDBALCleaner usage, which relies on doctrine/dbal connection.

  1. use Lamoda\Cleaner\DB\Config\DBCleanerConfigFactory;
  2. use Lamoda\Cleaner\DB\DoctrineDBALCleaner;
  3. $config = DBCleanerConfigFactory::create([
  4. 'query' => "DELETE * FROM big_table WHERE created_at < NOW() - (:interval || ' days')::interval",
  5. 'parameters' => [
  6. 'interval' => 90,
  7. ],
  8. ]);
  9. /** @var \Doctrine\DBAL\Connection $connection */
  10. $connection = $entityManager->getConnection();
  11. $cleaner = new DoctrineDBALCleaner($connection, $config);
  12. $cleaner->clear();