Out of pure curiosity, I try to understand how relational Active Records work.
For example, there are two tables in different databases.
The object table from DB-1 has a field device_id.
The table device from DB-2 has an id field.
There is an Object model, it has a connection with the Device model.
public function relations() { return array( 'device' => array(self::HAS_ONE, 'Device', 'id')) }
Upon request
var_dump($object->device);
everything is working.
The question is: how does yii determine which particular record to pull from the database if the tables do not have foreign keys and they lie in different databases?
How or where in the code is it determined that Object :: device_id matches Device :: id ?
Ps Theory is also good, but the code is still better. Just stick your nose where to look. I myself have not figured it out yet.