Answers.Body: <p>You first need to query for the “airport” entry by using the <code>first()</code> method. <code>$airport-&gt;myEntriedFieldHandle</code> then returns an ElementCriteriaModel prepared to get all the entries selected in the Entries field.</p>
  
  <pre class="lang-php prettyprint-override"><code>$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::Entry);
  $criteria-&gt;section = 'airports';
  $criteria-&gt;airportcode = 'BCN';
  $airport = $criteria-&gt;first();
  
  if ($airport) {
      $criteria = $airport-&gt;prefHotels;
      $airportPrefHotels = $criteria-&gt;find();
  
      if ($airportPrefHotels) {
          // do useful things with $airportPrefHotels
      }
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-31T18:51:31.773Z
Answers.LastActivityDate: 2017-05-31T18:51:31.773Z
Answers.UserDisplayName: carlcs
Body: <p>I'm trying to bring back a list of entries from a section. Currently I have the following:</p>
  
  <pre><code>$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::Entry);
  $criteria-&gt;section = 'airports';
  $criteria-&gt;airportcode = 'BCN';
  $airportPrefHotels = craft()-&gt;elements-&gt;findElements($criteria);
  </code></pre>
  
  <p>The airport section has a multiple entries field. I want to loop over them.</p>
  
  <p>Is it possible?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-05-31T17:58:08.210Z
Comments.Text: What type of field is `airportcode`? Also, you tagged this with `craft3`, but I assume you're referring to Craft 2 here, correct?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-05-31T18:01:41.610Z
Comments.Text: It wouldn't let me add craft 2.
  
  airportCode is a text field inside the section.
  
  I want to access the entries inside the field attached to the airport section
Comments.UserDisplayName: Christophfen
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-05-31T18:24:45.947Z
Comments.Text: So inside of an entry inside of a section with a handle of `airports`, you've got an [entries field] for relating other entries. What's the name of that field? And do you want to loop over all of those related entries for every parent entry?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-05-31T18:54:26.233Z
Comments.Text: I’m assuming there only one airport matching that criteria? If that’s right see my answer below @Christophfen
Comments.UserDisplayName: carlcs
Tags: <entries><elementcriteriamodel>
Title: Entries inside controller
ThreadText: # Entries inside controller
  
  (Asked by: username_0 on 2017-05-31)
  
  I'm trying to bring back a list of entries from a section. Currently I have the following:
  
  ```
  $criteria = craft()->elements->getCriteria(ElementType::Entry);
  $criteria->section = 'airports';
  $criteria->airportcode = 'BCN';
  $airportPrefHotels = craft()->elements->findElements($criteria);
  
  ```
  
  The airport section has a multiple entries field. I want to loop over them.
  
  Is it possible?
  
  **Tags:** entries, elementcriteriamodel
  
  > **Comments:**
  > **username_1**: What type of field is `airportcode`? Also, you tagged this with `craft3`, but I assume you're referring to Craft 2 here, correct?  
  > **username_0**: It wouldn't let me add craft 2.  airportCode is a text field inside the section.  I want to access the entries inside the field attached to the airport section  
  > **username_1**: So inside of an entry inside of a section with a handle of `airports`, you've got an [entries field] for relating other entries. What's the name of that field? And do you want to loop over all of those related entries for every parent entry?  
  > **username_2**: I’m assuming there only one airport matching that criteria? If that’s right see my answer below @username_0  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2017-05-31. Score: 1 | Accepted answer
  
  You first need to query for the “airport” entry by using the `first()` method. `$airport->myEntriedFieldHandle` then returns an ElementCriteriaModel prepared to get all the entries selected in the Entries field.
  
  ```php
  $criteria = craft()->elements->getCriteria(ElementType::Entry);
  $criteria->section = 'airports';
  $criteria->airportcode = 'BCN';
  $airport = $criteria->first();
  
  if ($airport) {
      $criteria = $airport->prefHotels;
      $airportPrefHotels = $criteria->find();
  
      if ($airportPrefHotels) {
          // do useful things with $airportPrefHotels
      }
  }
  
  ```
  
  
  ---
  
  