From e7a614781985a5686092d62a48021066dc559e35 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 17 Jan 2016 15:27:18 -0500 Subject: Fix regression: make sql query compatible with Mysql --- app/Model/ProjectActivity.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'app') 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(); } } -- cgit v1.2.3