09-23-2009, 09:38 AM
[eluser]introvert[/eluser]
Hello,
I have 2 simple models with has_one relation:
When I want to relate those 2 records:
I get error that items_feeds table doesnt exist. Why would DM require additional table if there is has_one relation? If I try removing has_many from Feed model, I get the same result.
What am I doing wrong? Should I pass any additional data to DM in such cases?
Thanks in advance!
Hello,
I have 2 simple models with has_one relation:
Code:
class Feed extends DataMapper {
var $has_many = array('item');
function __construct() {
parent::DataMapper();
}
}
class Item extends DataMapper {
var $has_one = array('feed');
function __construct() {
parent::DataMapper();
}
}
When I want to relate those 2 records:
Code:
$f = new Feed();
$f->save();
$i = new Item();
$i->save();
$f->save($i);
I get error that items_feeds table doesnt exist. Why would DM require additional table if there is has_one relation? If I try removing has_many from Feed model, I get the same result.
What am I doing wrong? Should I pass any additional data to DM in such cases?
Thanks in advance!