Reputation: 347
The scenario:
A client
can make many requests
,
In the Request
model I have:
public function setTableDefinition() {
$this->hasColumn('ref_no', 'varchar', 20);
$this->hasColumn('client_id', 'int', 11);
}
public function setUp() {
$this -> setTableName('Request');
}
In the db client_id
is a foreign key referencing id
in client table.
How do I set up a one to many
relationship with clients in the setUp()
method, in both the Client Model and the Request MOdel?
Thanks,
Help appreciated.
Upvotes: 0
Views: 98
Reputation: 14747
hmm try something like this at Client model:
public function setUp() {
parent::setUp();
$this->hasMany('Request as requests',
array(
'refClass' => 'Request',
'local' => 'id',
'foreign' => 'client_id'
)
);
}
Upvotes: 1