title: Looping through associated data in CakePHP
body: <p>I am feeling my way through CakePHP, trying to replicate what I can already do in vanilla PHP.</p>
  
  <p>I have 2 tables, <code>events</code> and <code>eventlist</code>. <code>events</code> contains general information about an event. <code>eventlist</code> contains information that appears as a bullet-pointed list on each event page.</p>
  
  <p><code>eventlist</code> consists of an id, an event_id which links each entry to the relevant event in the <code>event</code> table, and a string that is displayed on the page. In vanilla PHP, I would simply <code>SELECT list_info FROM eventlist WHERE event_id = 1</code> or whatever, and loop through the resulting array.</p>
  
  <p>However, I have no idea where to start with this in CakePHP, and I'm not sure how i'd search for it to find out.</p>
  
  <p>I have already created an association between the two tables:</p>
  
  <pre><code>class Event extends AppModel{
  
      public $hasMany = array(
          'EventList'
          );
  
  }
  </code></pre>
  
  <p>class EventList extends AppModel{</p>
  
  <pre><code>public $useTable = 'eventlist';
  
  public $belongsTo = array(
      'Event'
  );
  </code></pre>
  
  <p>}</p>
  
  <p>And I have a simple view set up for <code>Event</code>:</p>
  
  <pre><code>&lt;h2&gt;&lt;?php echo $event['Event']['event_name'] ?&gt;&lt;/h2&gt;
  
  &lt;p&gt;&lt;?php echo $event['Event']['event_description']?&gt;&lt;/p&gt;
  
  &lt;h3&gt;£&lt;?php echo $event['Event']['event_cost']?&gt;&lt;/p&gt;
  </code></pre>
  
  <p>But now I have no idea what to do - I am new to CakePHP and MVC as a whole. I assume I need to do something in <code>EventListController</code> to load the data into an array. Any help appreciated.</p>