Home  >  Article  >  PHP Framework  >  How to configure the yii table prefix

How to configure the yii table prefix

藏色散人
藏色散人Original
2020-07-20 09:41:022209browse

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} }';}".

How to configure the yii table prefix

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!

Statement:
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