From ee8ec7685f95125c385d17dad41369a549ce9bbf Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Wed, 31 Dec 2014 14:15:42 -0500 Subject: Reduce the number of SQL queries for automatic actions --- app/Model/Action.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'app/Model') diff --git a/app/Model/Action.php b/app/Model/Action.php index 905b8914..95e22d27 100644 --- a/app/Model/Action.php +++ b/app/Model/Action.php @@ -140,9 +140,17 @@ class Action extends Base public function getAll() { $actions = $this->db->table(self::TABLE)->findAll(); + $params = $this->db->table(self::TABLE_PARAMS)->findAll(); foreach ($actions as &$action) { - $action['params'] = $this->db->table(self::TABLE_PARAMS)->eq('action_id', $action['id'])->findAll(); + + $action['params'] = array(); + + foreach ($params as $param) { + if ($param['action_id'] === $action['id']) { + $action['params'][] = $param; + } + } } return $actions; -- cgit v1.2.3