Definine authManager tables in modules

I know how to define authManager tables in the main application, and it works well:


	        'components'=>array(

		        'authManager'=>array(

		            'class'=>'CDbAuthManager',

		            'connectionID'=>'db',

			        'itemTable'=>'{{auth_item}}',

			        'itemChildTable'=>'{{auth_item_child}}',

			        'assignmentTable'=>'{{auth_assignment}}',

		        ),

		       'db'=>array(

		           'class'=>'CDbConnection',

		           'tablePrefix' => 'tbl_',

		           'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/db.sqlite',

		       ),

	        ),

However, this doesn’t work in modules, because it still takes the primary db connection, and not the db connection that I defined in the module.


	'modules'=>array(

            'blog'=>array(

	        'components'=>array(

		        'authManager'=>array(

		            'class'=>'CDbAuthManager',

		            'connectionID'=>'db',

			        'itemTable'=>'{{auth_item}}',

			        'itemChildTable'=>'{{auth_item_child}}',

			        'assignmentTable'=>'{{auth_assignment}}',

		        ),

		       'db'=>array(

		           'class'=>'CDbConnection',

		           'tablePrefix' => 'tbl_',

		           'connectionString'=>'sqlite:'.dirname(__FILE__).'/../modules/blog/data/bldog.sqlite',

		       ),

	        ),

            ),

I can change the db connection with this article instructions, but I don’t know how to make the authManager tables work. What should I do?

I found the solution to the problem. I added this to the main class of the module:


~~~

[php]

public function init()

{

        $this->setImport(array(

                'blog.models.*',

                'blog.components.*',

        ));


       Yii::app()->setComponents(

        	array(

		       'db'=>array(

		           'class'=>'CDbConnection',

		           'tablePrefix' => 'tbl_',

		           'connectionString'=>'sqlite:' .dirname(__FILE__) . '/data/blog.sqlite',

		       ),

		        'authManager'=>array(

		            'class'=>'CDbAuthManager',

		            'connectionID'=>'db',

			        'itemTable'=>'tbl_auth_item',

			        'itemChildTable'=>'tbl_auth_item_child',

			        'assignmentTable'=>'tbl_auth_assignment',

			     )

		);		

       }

}

~~~