Revision #32 has been created by rackycz on Sep 20, 2019, 10:44:12 AM with the memo:
db
« previous (#31) next (#33) »
Changes
Title
unchanged
Yii v2 for beginners
Category
unchanged
Tutorials
Yii version
unchanged
2.0
Tags
unchanged
tutorial,beginner,yii2
Content
changed
[...]
CREATE TABLE IF NOT EXISTS `user` (
`id` INT NOT NULL AUTO_INCREMENT,
`username` VARCHAR(45) NOT NULL,
`password` VARCHAR(60) NOT NULL,
`email` VARCHAR(60) NOT NULL,
`authKey` VARCHAR(60),
PRIMARY KEY (`id`))
ENGINE = InnoDB;[...]
- When creating the model, check this checkbox: **Enable I18N** ... we will need i18n later
- Note that there already is a model named User in the demo app. You will not need it if you want to use login-via-DB so feel free to check "Overwrite" in GII. The newly created User model will now be usable only for table operations, not for login. But we will enhance it, keep reading.
- The new model will only have 3 methods: tableName(), rules(), attributeLabels()
- In order to use the DB for login, we need to implement IdentityInterface which requires [5 new methods](https://www.yiiframework.com/doc/api/2.0/yii-web-identityinterface). But as I do not need all those methods, in some of them I have commented out their body in the example below.
Login via database + Session
---
... text ...[...]