4spacesdk / CI4OrmExtension

OrmExtension for CodeIgniter 4
MIT License
50 stars 9 forks source link

Not pre-fetching include #4

Closed Schop closed 4 years ago

Schop commented 4 years ago

Although the documentation says that relationship data is prefetched, I can't get it to work.

Working example from controller:

$matchModel = new MatchModel();
$match = $matchModel->includeRelated(VenueModel::class)->find(1);
$match->venue->find();
echo $match->venue->name;

This actually does echo the Venue name, but this next example does not, although the documentation says it should:

$matchModel = new MatchModel();
$match = $matchModel->includeRelated(VenueModel::class)->find(1);
//$match->venue->find();
echo $match->venue->name;
Martin-4Spaces commented 4 years ago

Take a look at the writeable/cache folder. I think OrmExtension has cached som old field data :) You can either delete the cache files manually, or create a spark command to do it. Use this code to clear the cache: ModelDefinitionCache::getInstance()->clearCache();

Schop commented 4 years ago

Thank you, that fixed that problem!