Kohana 3身份验证模块,使用户具有“工作人员"或“经理"角色 [英] Kohana 3 auth module, getting users with 'staff' or 'manager' role
本文介绍了Kohana 3身份验证模块,使用户具有“工作人员"或“经理"角色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在学习框架,现在使用它来构建应用程序.
I'm learning the framework, and now building an application using it.
我需要让所有具有'user'或'staff'角色的用户使用,但是我无法在文档中找到它.
I need to get all users that have 'user' or 'staff' role, but I couldn't find about it on the documentation.
帮助任何人吗? (我认为auth模块更多是一个ORM问题)
Help anyone? (I think it's more an ORM problem the the auth module)
推荐答案
我找不到使用ORM进行此操作的简便方法,但是我有一种解决方法.
这是我的代码,适合可能与我遇到相同问题的任何人.
I didn't find an easy way to do this using the ORM, but I have a workaround.
This is my code for anyone who might encounter the same problem with me.
// One for each role
$staffs = ORM::factory('role', array('name' => 'staff'))->users->find_all()->as_array();
$managers = ORM::factory('role', array('name' => 'manager'))->users->find_all()->as_array();
// Merge the results
$results = array_merge($staffs, $managers);
这篇关于Kohana 3身份验证模块,使用户具有“工作人员"或“经理"角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文