Hi,
I’ve got an object related by one->many relationships to several other objects, e.g.:
Voucher->VoucherRegion
If I submit a form which changes the Regions a Voucher is associated with (e.g. so the Voucher goes from being associated with London & Birmingham to London, Birmingham & Manchester), first of all links to any Regions that have been removed are deleted from the database, and then new links are added with the following:
while($newRegion = array_pop($newRegions))
{
$obj = $this->xpdo->newObject('VoucherRegion');
$obj->set('voucher', $this->getPrimaryKey());
$obj->set('region', $newRegion);
$obj->save();
$this->addMany($obj);
}
A new object is created, populated and saved.
Later on, when I try to retrieve all of the Voucher’s relationships to Regions (with $regions = $this->getMany(’VoucherRegion’)), and then iterate through the retrieved objects, none of the newly added regions are returned.
I haven’t set up caching anywhere, and if I query the database directly, it says that the correct number of entries are in the database, so the save() method is being executed correctly.
If I refresh the page, the Regions are returned correctly.
Is there any way I can force xPDO to refresh its cache? Or is the call wrong? Perhaps it isn’t a caching issue since if I remove a Region, that one isn’t returned when I call getMany(). It’s just newly added Regions that aren’t returned. I’m not setting a cacheFlag anywhere either.
Any help would be appreciated.
Thanks