Pergunta

I'm following along in the Yii book and am on CH5 (page 101). In our unit tests, it has us define an array that specifies which fixture(s) to use:

class ProjectTest extends CDbTestCase {
}
public $fixtures=array (
'projects'=>'Project', );

But, the fixtures file is created in 'protected/tests/fixtures/tbl_project.php' and clearly isn't named 'projects'. How does Yii infer this? Note: my DB table is named tbl_project.

Thanks :)

Foi útil?

Solução

you need to define table prefix for your db and then create the models again. This is how your 'db' definition would look like if you are using mysql (in config > main.php under 'components')

    'db'=>array(
        'connectionString' => 'mysql:host=localhost;dbname=test',
        'emulatePrepare' => true,
        'username' => 'root',
        'password' => '',
        'charset' => 'utf8',
                    'tablePrefix'=>'tbl_',
    ),

Once you have the prefix in place, yii should be able to name your models excluding the prefix.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top