class Parent extends Model
{
public $table = 'db1.parent';
protected function init(): void
{
parent::init();
$this->addField('name');
$this->hasMany('children', ['model' => [Child::class]]);
}
}
class Child extends Model
{
public $table = 'db2.child';
protected function init(): void
{
parent::init();
$this->addField('name');
$this->hasOne('parent_id', ['model' => [Parent::class]]);
}
}
With those classes, the code:
$p = new Parent($db);
$c = $p->ref('children');
will generate an exception "Atk4\Data\Exception: Their model does not contain fallback field" as it will attempt to reference a their_fallback_field of 'db1.parent_id' (it should be simply 'parent_id').
Adding "their_field' => 'parent_id' to the hasMany definition resolves this, but shouldn't be necessary
With two classes:
With those classes, the code:
will generate an exception "Atk4\Data\Exception: Their model does not contain fallback field" as it will attempt to reference a their_fallback_field of 'db1.parent_id' (it should be simply 'parent_id').
Adding "their_field' => 'parent_id' to the hasMany definition resolves this, but shouldn't be necessary