Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set table prefix in Yii

Tags:

php

yii

In a project I am working on I need to set a table prefix for the project which I can change later. Browsing through the docs I came across this : http://www.yiiframework.com/doc/api/1.1/CDbConnection#tablePrefix-detail

But it is not explained where I implement this. I mean should I put it in protected/config/main.php or edit the core files ?

like image 897
ajaybc Avatar asked May 18 '12 04:05

ajaybc


1 Answers

You put it in the config file, along with other db configuration, like this:

'db'=>array(
  'connectionString' => 'xxxxx',
  'username' => 'xxxxx',
  'password' => 'xxxxx',
  'tablePrefix' => 'tbl_',
),

All public properties of any component can be set in the config file this way.

like image 127
DCoder Avatar answered Nov 07 '22 00:11

DCoder