Yii Framework Forum: Can AR relation work on tables sitting in two database? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Can AR relation work on tables sitting in two database? Rate Topic: -----

#1 User is offline   tc74 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 26-June 10

Posted 18 November 2010 - 08:16 AM

I have a main database that contain information like user, country and cities. I have another database contain business listing. I wrote a relation between the table but it failed. Just want to confirm can relation work across database?

class User extends CActiveRecord
{...
public function getDbConnection()
{
return A;
}

class UserBusiness extends CActiveRecord
{...
public function getDbConnection()
{
return A
}
...
public function relations()
{
return array(
'user' => array(self::HAS_ONE, 'User', 'user_id'),
'business' => array(self::HAS_ONE, 'Business', 'business_id'),
);
}

class Business extends CActiveRecord
{...
public function getDbConnection()
{
return B;
}
0

#2 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 18 November 2010 - 08:29 AM

At least not with eager loading, not sure about lazy loading. Eager loading uses JOINs which don't work over multiple connections for obvious reasons.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users