diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-01-17 15:27:18 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-01-17 15:27:18 -0500 |
commit | e7a614781985a5686092d62a48021066dc559e35 (patch) | |
tree | d0d5b9b514f2078e8a334bf13ac6dd3a0f80b635 | |
parent | e94c4cab7f79657f8b514b4af6c4e459e9b42961 (diff) |
Fix regression: make sql query compatible with Mysql
-rw-r--r-- | app/Model/ProjectActivity.php | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/app/Model/ProjectActivity.php b/app/Model/ProjectActivity.php index d3aeefe5..74df26a1 100644 --- a/app/Model/ProjectActivity.php +++ b/app/Model/ProjectActivity.php @@ -168,9 +168,11 @@ class ProjectActivity extends Base */ public function cleanup($max) { - if ($this->db->table(self::TABLE)->count() > $max) { - $subquery = $this->db->table(self::TABLE)->desc('id')->limit($max)->columns('id'); - $this->db->table(self::TABLE)->notInSubquery('id', $subquery)->remove(); + $total = $this->db->table(self::TABLE)->count(); + + if ($total > $max) { + $ids = $this->db->table(self::TABLE)->asc('id')->limit($total - $max)->findAllByColumn('id'); + $this->db->table(self::TABLE)->in('id', $ids)->remove(); } } |