title: Codeigniter defining variable in controller vs passing to model
body: <p>I'm wondering which method is better from a best practices perspective:</p>
  
  <p><strong>Option 1:</strong></p>
  
  <p><em>Controller:</em></p>
  
  <pre><code>$this-&gt;data['my_var'] = 'some value';
  $response = $this-&gt;My_model-&gt;some_method();
  </code></pre>
  
  <p><em>Model:</em></p>
  
  <pre><code>function some_method()
  {
      $var = $this-&gt;data['my_var'];
      //do stuff
  } 
  </code></pre>
  
  <p><strong>Option 2:</strong></p>
  
  <p><em>Controller:</em></p>
  
  <pre><code>$this-&gt;data['my_var'] = 'some value';
  $response = $this-&gt;My_model-&gt;some_method($this-&gt;data['my_var']);
  </code></pre>
  
  <p><em>Model:</em></p>
  
  <pre><code>function some_method($myVar)
  {
      //do stuff with $myVar
  } 
  </code></pre>
  
  <p>Essentially the difference being passing the variable as a parameter, or defining the variable as a part of the data array and accessing it inside the model.</p>