Skip to content

cleanDb() Code for MySql systems only? #15

@HebisJC

Description

@HebisJC

EBackJob->cleanDb() doesn't work for me on SQLite. The problem here seems to be the following line, uses code which is not fully compatible on other DB-Systems: $historyStart = "DATE_SUB(NOW(), INTERVAL :history DAY)";

This solution worked for me:

$driver = Yii::app()->getComponent($this->databaseComponent)->getDriverName();
       
 switch ($driver) {
     case 'sqlite':
         $historyStart = "datetime('now', '-' || :history || ' days')";
         break;
     case 'pgsql':
         $historyStart = "CURRENT_TIMESTAMP - (:history || ' days')::interval";
         break;
     default:
         $historyStart = "DATE_SUB(NOW(), INTERVAL :history DAY)";
 }

Version: v0.65.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions