Skip to content
Advertisement

How to change the database connection in YII

I have yii application,, and i want to change the database connection.. first, my app is connect to ‘trackstar’ database, and later i want to change to ‘taskmanagement’ database..

So i just simply change the dbname in my code :

JavaScript

but when i run the app i got error :

CDbCommand failed to execute the SQL statement: SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘trackstar.tbl_auth_assignment‘ doesn’t exist. The SQL statement executed was: SELECT * FROM tbl_auth_assignment WHERE userid=:userid

the thing i dont understand is that why is still connect to trackstar database eventhough i just change the dbname to taskmanagement

thx before 🙂

Advertisement

Answer

You are only configure the console.php Configuration . But Yii Web application use the main.php

Check your main.php file

its located on Your App folder -> Protected -> config ->main.php

Change Db connection on this file

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement