A
A
Alexander Sinitsyn2016-08-17 09:38:05
Kohana
Alexander Sinitsyn, 2016-08-17 09:38:05

How can one make a single request without a loop?

Is it possible to query all user roles at once without a loop?

foreach ($this->roles as $role) {
            $access = (ORM::factory('Role', $role)
                    ->permission
                    ->where_open()
                    ->where('directory', '=', $this->request->directory())
                    ->or_where('directory', '=', '')
                    ->or_where('directory', 'is', NULL)
                    ->where_close()
                    ->and_where_open()
                    ->where('controller', '=', $this->request->controller())
                    ->or_where('controller', '=', '')
                    ->or_where('controller', 'is', NULL)
                    ->and_where_close()
                    ->and_where_open()
                    ->where('action', '=', $this->request->action())
                    ->or_where('action', '=', '')
                    ->or_where('action', 'is', NULL)
                    ->and_where_close()
                    ->count_all() > 0);
            if ($access)
                break;
        }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mr Hobot, 2016-08-17
@vashaaa

Can.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question