title: CodeIgniter - constructors in models
body: <p>So here is my controller:</p>
  
  <pre><code>class Search extends CI_Controller {
  
      public function __construct() {
          parent::__construct();
          $this-&gt;load-&gt;model('search_model');
          $this-&gt;search_model-&gt;search_result = $_POST;
      }
  
      public function index()
      {
  
          $data['results'] = $this-&gt;search_model-&gt;get_results();
          $this-&gt;load-&gt;view('search_results', $data);
      }
  </code></pre>
  
  <p>And here is my model:</p>
  
  <pre><code>class Search_model extends CI_Model {
  
      protected $search_query;
  
      function __construct($search_query)
      {
          parent::__construct();
          $this-&gt;load-&gt;database();
          $this-&gt;search_query = $search_query;
      }
  </code></pre>
  
  <p>But this doesn't seem to work. What I want to do is pass the posted form ($_POST) to my model, then do stuff with it. But it seems messy to pass $_POST to each method of my model. My plan is to extract the variables sent with $_POST and construct these as properties such as $website_url, $text_query etc..., then call these in methods with $this->website_url;</p>
  
  <p>I'm relatively new to CodeIgniter so just getting to grips with the basics</p>