• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with MVC and passing the query data

#1
[eluser]michalo[/eluser]
Hi, I'm new in Code Igniter framework so perhaps my problem is very easy to you, but I viewed many post and I couldn't resolve it.

I have following error:
Fatal error: Call to a member function get_search_results() on a non-object in D:\Program Files\VertrigoServ\www\application\controllers\propozycje.php

A PHP Error was encountered
Message: Undefined property: Propozycje::$Propozycje_model
Filename: controllers/propozycje.php

My controller file (located in: controllers/propozycje.php):
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Propozycje extends CI_Controller {
        
    public function search()
    {
        extract($_POST); //here I have variables: $pieniadze, $dla_kogo
        
        $this->load->model('propozycje_model');
        $data['wynik'] =  $this->Propozycje_model->get_search_results($pieniadze, $dla_kogo);
        $this->load->view('propozycje_view', $data);
    }
}

Here is my model file (located in: models/propozycje_model.php):
Code:
<?php
class Propozycje_model extends CI_Model {


     function __construct()
     {
         // Call the Model constructor
         parent::__construct();
     }
    
     function get_search_results($pieniadze, $dla_kogo)
     {    
    $query= $this->db->query('SELECT nazwa, opis FROM propozycje WHERE '.$pieniadze.'<=wymaganePieniadze AND dlaKogo='.$dla_kogo.';');
        return $query->result();
     }


}
?&gt;
And my view (located in: views/propozycje_view.php):
Code:
<!DOCTYPE html>
&lt;html lang="en"&gt;
&lt;head&gt;
    &lt;meta charset="utf-8"&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;?php    
foreach($wynik as $row)    
{
  echo  $row->nazwa . '<br />';
  echo  $row->opis . '<br />';
} ?&gt;

&lt;/body&gt;
&lt;/html&gt;

Could you help me what's wrong in code above?


Messages In This Thread
Problem with MVC and passing the query data - by El Forum - 06-24-2011, 05:02 PM
Problem with MVC and passing the query data - by El Forum - 06-24-2011, 05:06 PM
Problem with MVC and passing the query data - by El Forum - 06-24-2011, 05:19 PM
Problem with MVC and passing the query data - by El Forum - 06-24-2011, 05:47 PM
Problem with MVC and passing the query data - by El Forum - 06-24-2011, 06:15 PM
Problem with MVC and passing the query data - by El Forum - 06-24-2011, 06:41 PM
Problem with MVC and passing the query data - by El Forum - 06-24-2011, 06:49 PM
Problem with MVC and passing the query data - by El Forum - 06-24-2011, 06:57 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.