在我正在处理的项目中,我需要为项目设置一个表前缀,以后可以更改。浏览文档时我遇到了这个:http://www.yiiframework.com/doc/api/1.1/CDbConnection#tablePrefix-detail
但是没有解释我在哪里实现这一点。我的意思是我应该把它放在受保护/配置/主.php还是编辑核心文件?
你把它和其他数据库配置放在配置文件中,如下所示:
'db'=>array(
'connectionString' => 'xxxxx',
'username' => 'xxxxx',
'password' => 'xxxxx',
'tablePrefix' => 'tbl_',
),
任何组件的所有公共属性都可以通过这种方式在配置文件中设置。
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=###',
'emulatePrepare' => true,
'username' => '###',
'password' => '###',
'charset' => '###',
'tablePrefix' => 'r_',
),