yii表前綴怎么配置

YII表前綴的配置方法:首先對component中db的配置進行修改;然后在相應的model中修改tablename屬性,修改語句如“public function tableName(){return ‘{{%user}}’;}”。

yii表前綴怎么配置

yii2配置表前綴

前綴設置

component中db的配置修改

'db'=>array( 'connectionString'?=>?'mysql:host=localhost;dbname=xxxx', 'emulatePrepare'?=>?true, 'username'?=>?'root', 'password'?=>?'', 'charset'?=>?'utf8', 'tablePrefix'?=>?'tb_',???//加入前綴名稱fc_ ),

?推薦:《yii教程

然后在相應的model中修改tablename屬性如下:

例如model? ?的? User中

修改為:

public?function?tableName() { return?'{{%user}}'; }

? 版權聲明
THE END
喜歡就支持一下吧
點贊11 分享