Home > Backend Development > PHP Tutorial > How to modify the user table used for user login in yii2.0 to another table

How to modify the user table used for user login in yii2.0 to another table

不言
Release: 2023-04-01 11:20:02
Original
1468 people have browsed it

The following will bring you an article on how to modify the user table used for yii2.0 user login to other tables. The content is quite good, so I will share it with you now and give it as a reference.

This is just a record of my own practice.

For some reason, I don’t want to use the user table that comes with Yii. I want to use the admin database table I built myself. Modify it as follows:

1. Refer to common\models\User in the advanced template and modify Admin

2. Modify

'user' => [ 
   //'identityClass' => 'common\models\User', 
   'identityClass' => 'common\models\Admin', 
   'enableAutoLogin' => true,
Copy after login

3 in the configuration file. LoginForm getUser(), modified to get the user from the admin table

The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

How to create simple widgets with yii2.0

Yii paging using CLinkPager

The above is the detailed content of How to modify the user table used for user login in yii2.0 to another table. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template