- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我现在正在使用ion_auth,在 ion_auth 中,我们可以像这样选择所有记录:
Controller
public function index($group_id = NULL) {
$before_head = $this->load->view('admin/users/v_before_head', '', TRUE);
$before_body = $this->load->view('admin/users/v_before_body', '', TRUE);
$this->data['page_title'] = 'Users';
$this->data['before_head'] = $before_head;
$this->data['before_body'] = $before_body;
$this->data['users'] = $this->ion_auth->users($group_id)->result();
$this->render('admin/users/v_list_users');
}
我的情况是,我在名为 id_departement 的默认表 ion_auth 中又添加了一列,它是来自另一个表的外键,如下所示:
MariaDB [ittresnamuda]> select * from tb_departement;
+----------------+------------------+-------+
| id_departement | nama_departement | alias |
+----------------+------------------+-------+
| 1 | ACCOUNTING | ACC |
| 2 | ARMADA | AMD |
| 3 | DIREKSI | DIR |
| 4 | EKSPOR | EXP |
| 5 | FINANCE | FIN |
| 6 | IMPORT | IMP |
| 7 | IT | IT |
| 8 | INVENTORY | INV |
| 9 | MARKETING | MKT |
| 10 | PERSUM | HRD |
| 11 | PURCHASING | PRC |
| 12 | OPERATION | OPS |
| 13 | LEGAL & CLAIM | LCL |
| 14 | SEKRETARIAT | SKRT |
+----------------+------------------+-------+
14 rows in set (0.00 sec)
这是 ion_auth 表:
MariaDB [ittresnamuda]> select id, username, email, id_departement from users LIMIT 20;
+----+---------------+--------------------------+----------------+
| id | username | email | id_departement |
+----+---------------+--------------------------+----------------+
| 1 | administrator | admin@admin.com | NULL |
| 5 | Dzil | dzil@tresnamuda.co.id | 1 |
| 19 | David | david_vl@indo.net.id | 3 |
| 20 | Emmy | emmy@indo.net.id | 5 |
| 21 | Hendrik | hl_kong@indo.net.id | 3 |
| 22 | ATaufiq | taufik@tresnamuda.co.id | 1 |
| 23 | Awal | awal@tresnamuda.co.id | 1 |
| 24 | Riana | riana@tresnamuda.co.id | 1 |
| 25 | Nugroho | accjkt@tresnamuda.co.id | 1 |
| 26 | Dudung | accjkt@tresnamuda.co.id | 1 |
| 27 | Farida | accjkt@tresnamuda.co.id | 1 |
| 28 | Nita | accjkt2@tresnamuda.co.id | 1 |
| 29 | Rayen | accjkt2@tresnamuda.co.id | 1 |
| 30 | Taka | accjkt@tresnamuda.co.id | 1 |
| 31 | Anjar | accjkt2@tresnamuda.co.id | 1 |
| 32 | Toni | accjkt@tresnamuda.co.id | 1 |
| 33 | Sukardi | sukardi@tresnamuda.co.id | 2 |
| 34 | Tiur | tiur@tresnamuda.co.id | 2 |
| 35 | Yuti | amdjkt@tresnamuda.co.id | 2 |
| 36 | Erfin | erfin@tresnamuda.co.id | 2 |
+----+---------------+--------------------------+----------------+
一组 20 行(0.00 秒)
如何使用 ion_auth 事件记录获取 name_departement 和别名?
最佳答案
使用钩子(Hook),您可以在调用 ion_auth 的 users 方法之前修改数据库查询,因此它将与您的表连接,如下所示:
class MyController extends CI_Controller {
// callback function to add join to db before call users method
public function prepare_user_list() {
$this->db->join('tb_departement','tb_departement.id_departement = ' . 'users.id_departement','inner');
}
public function index($group_id = NULL) {
$before_head = $this->load->view('admin/users/v_before_head', '', TRUE);
$before_body = $this->load->view('admin/users/v_before_body', '', TRUE);
$this->data['page_title'] = 'Users';
$this->data['before_head'] = $before_head;
$this->data['before_body'] = $before_body;
// subscribe for the users event
$this->ion_auth->set_hook('users', 'prepare_user_list', $this, 'prepare_user_list', array());
// then query the users
$this->data['users'] = $this->ion_auth->users($group_id)->result();
$this->render('admin/users/v_list_users');
}
}
关于mysql - ion_auth 与另一个表连接的事件记录/方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36325341/
如何检查用户是否登录在 View 中?? 类似这样的: if ($this->ion_auth->logged_in()) { // do something .. } else {
我已经敲了 5 个小时的头,终于解决了问题,但我就是在不知道原因的情况下无法休眠。让我先解释一下这个问题。 我使用了 codeigniter HMVC 扩展并将 ion_auth 作为单独的模块安装。
我正在为我的应用程序使用 codeigniter 和 Ion_auth。安装了它们,它们工作得很好......这是我第一次真正不得不进入并使用 codeigniter 进行自定义重定向(codeign
我现在正在使用ion_auth,在 ion_auth 中,我们可以像这样选择所有记录: Controller public function index($group_id = NULL) {
所以我要转移到新的主机服务器。我在旧服务器上使用的一个学校项目必须保持正常运行,不得停机,因此我正在准备新服务器并移动所有关联的文件。我已将虚拟主机设置完毕并正常工作,但现在 CodeIgniter
我是一名优秀的程序员,十分优秀!