Skip to content

cleanDb() Code for MySql systems only? #15

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions