Yii table prefix configuration method: first modify the db configuration in the component; then modify the tablename attribute in the corresponding model, modify the statement such as "public function tableName(){return '{{%user} }';}".
yii2 configuration table prefix
Prefix setting
Configuration modification of db in component
'db'=>array( 'connectionString' => 'mysql:host=localhost;dbname=xxxx', 'emulatePrepare' => true, 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'tablePrefix' => 'tb_', //加入前缀名称fc_ ),
Recommendation: "yii tutorial"
Then modify the tablename attribute in the corresponding model as follows:
For example, in model User
Modify to:
public function tableName() { return '{{%user}}'; }
The above is the detailed content of How to configure the yii table prefix. For more information, please follow other related articles on the PHP Chinese website!