can we write code in relations function for multiple databases

I am creating the API for in Yii Framework.

I have users table in DB_1, userBooks table in DB_2. I my page I am overriding the relations. Please see the bellow code.

public function relations()


// NOTE: you may need to adjust the relation name and the related

// class name for the relations automatically generated below.

return array(

            'userBooks' => array(self::HAS_MANY, 'userbooks', 'userid'),


Please check the code and please give me replay. I’ll help me lot.

Please let me know, if we have any other solutions to make relations for two databases.