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 :
<?php
// This is the configuration for yiic console application.
// Any writable CConsoleApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Console Application',
// application components
'components'=>array(
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=taskmanagement',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
),
'authManager'=>array(
'class'=>'CDbAuthManager',
'connectionID'=>'db',
'itemTable' => 'tbl_auth_item',
'itemChildTable' => 'tbl_auth_item_child',
'assignmentTable' => 'tbl_auth_assignment',
),
),
);
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 :)
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