Create model instance in console command

Hello, I try to create instance of certain model in console command, but first I getting errors about that Yii could not find model class, then I do this


Yii::import('application.models.*');

, and now I get new this error


'The table "{{user}}" for active record class "User" cannot be found in the database.'

. In database table called tbl_user. I try to search on another related topics but I didnt find the solution for this problem.

Most likely you forgot to configure the db connection.

Ronald is probably right - console application has by default different config file: console.php.

If you mean this


'db' => array(

            'connectionString' => 'mysql:host=localhost;dbname=chooseone',

            'emulatePrepare'   => true,

            'username'         => '****',

            'password'         => '****',

            'charset'          => 'utf8',

        ),

block in console.php, I can assure you this configured. Or you mean connection for a certain command ?

Your model is looking for table ‘User’ but you have table with name ‘tbl_user’.

even if I cahnge it to ‘tbl_user’ I’ll getting the same error!

Could you, please, show code of your Model?

I found the solution, I just forgot to configure ‘tablePrefix’ property for db connection.