How to declare M2M relationships if the join table is in a different database?

For example, posts table is in database1, categories table and category_post_join table are in database2, then how to declare a many-to-many relationship between Post model and Category model?

'categories'=>array(self::MANY MANY, 'Category', 'category_post_join (post_id, category_id)')

works only if all tables are in the same database.

The current implementation of AR doesn’t support this.