Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You should be using the containable behavior for this. More at: <a href="http://book.cakephp.org/view/1323/Containable" rel="nofollow">http://book.cakephp.org/view/1323/Containable</a></p> <ol> <li>Add it to your Competitor model.</li> </ol> <pre><code> var $actsAs = array('Containable'); </code></pre> <ol> <li>Update your model relationships in your Competitor model to include the is_black and is_adult conditions:</li> </ol> <pre><code> var $hasAndBelongsToMany = array( 'Competitor' => array( 'className' => 'Competitor', 'joinTable' => 'event_competitors', 'alias' => 'EventCompetitor', 'conditions' => array( 'EventCompetitor.is_black' => 0, 'EventCompetitor.is_adult' => 0 ) ) ); </code></pre> <p>3) To inject the event id, pass a contain array to your find operation:</p> <pre><code>$contain = array( 'EventCompetitor' =&gt; array( 'conditions' =&gt; array('EventCompetitor.event_id' =&gt; $current_matchsc['Event']['id']) ) ); $matchdivisions = $this-&gt;Competitor-&gt;find("all" , array( 'contain' =&gt; $contain, 'conditions' =&gt; array( 'Competitor.status' =&gt; 1, 'Competitor.payment_completed' =&gt; 1, 'Competitor.weightgroup_id' =&gt; $current_matchsc['Matchschedule']['weightgroup_id'], 'Competitor.rank_id' =&gt; $current_matchsc['Matchschedule']['rank_id'], 'Competitor.degree_id' =&gt; $current_matchsc['Matchschedule']['degree_id'], 'Competitor.gender' =&gt; $current_matchsc['Matchschedule']['gender'] ) ) ); </code></pre> <p>If is_black and is_adult are not always required for the relationship, you would want to move those conditions from the model and pass them in via the contain parameter of the find operation as needed.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload