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

How to configure the yii table prefix

藏色散人
Release: 2020-07-20 09:41:02
Original
2229 people have browsed it

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_
),
Copy after login

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}}';
}
Copy after login

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!

Related labels:
yii
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