I have the following code:
$criteria = craft()->elements->getCriteria(ElementType::Entry);
$criteria->section = 'submissions';
// Loop
foreach ($criteria as $entry)
{
echo $entry->id.'<br />';
echo $entry->title.'<br />';
echo $entry->sport.'<br />';
}
The sport field is an Entry field, pointing to an entry in a different channel. My question is, how can I get the data from the related entry (i.e. the title) without an extra query per row? Can I eager load it? Or get the sport entries in a separate query and then combine the data?
I need to get the title of the related sport entry. The following works but gives an extra query for every row:
$entry->sport->first()['title'];
Anyone? Thanks in advance