前缀设置
component中db的配置修改
'db'=>array('connectionString' => 'mysql:host=localhost;dbname=xxxx','emulatePrepare' => true,'username' => 'root','password' => '','charset' => 'utf8','tablePrefix' => 'tb_', //加入前缀名称fc_),
然后在相应的model中修改tablename属性如下:
例如model 的 User中
修改为:
public function tableName(){return '{{%user}}';}
本文介绍如何在YII框架中配置数据库连接,并演示如何为数据表添加前缀,同时更新对应的Model以匹配新的表名。
1794

被折叠的 条评论
为什么被折叠?



