title: Should you use arguments in the view?
body: <p>I am trying to figure out a best practice for MVC. Should I 
   1. Create a function in the model that takes in an argument? (And then provide that argument in the view) 
   2. Create a function in the model that DOES NOT take an argument. Instead pass in the value that I need within the model itself</p>
  
  <p>This is an example of #1. Note that this is inside my view. </p>
  
  <pre><code>// this selects the desired food id 
  $food_id = favfoods::model()-&gt;selectedfav();
  // this then uses that selected foodid as an argument to the function favpeople 
  $people = People::model()-&gt;favpeople($food_id); 
  </code></pre>
  
  <p>This is an example of #2. Note that this is inside the model, and that the function favpeople no longer takes an argument.</p>
  
  <pre><code>public function favpeople() 
      {
          // this gets the necessary food_id.
          $food_id = favfoods::model()-&gt;selectedfav(); 
  
          // This selects the id of the person who matches the "food_id"
          $favpeeps = 'SELECT personid FROM people WHERE food_id = "'.$food_id.'"';
  
          // This implements the query.
          $result=yii::app()-&gt;db-&gt;createCommand($favpeeps)-&gt;queryAll();
  
          // The result is an array, so I loop through the array to return the personid that I want. 
          foreach($result as $count)
          {
  
              return $count['personid'];
          }
      }
  </code></pre>
  
  <p>Which is better practice 1. Calling two functions in the view and having one of the functions be the argument of the other. Or 2. Do the dirty work of using arguments in advance in the model? </p>