Problem with MVC and passing the query data - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Problem with MVC and passing the query data (/showthread.php?tid=42964) |
Problem with MVC and passing the query data - El Forum - 06-24-2011 [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'); Here is my model file (located in: models/propozycje_model.php): Code: <?php Code: <!DOCTYPE html> Could you help me what's wrong in code above? Problem with MVC and passing the query data - El Forum - 06-24-2011 [eluser]osci[/eluser] your query is wrong. Code: <=wymaganePieniadze Problem with MVC and passing the query data - El Forum - 06-24-2011 [eluser]michalo[/eluser] Sorry for stupid question, but what exaclly is wrong? wymaganePieniadze is INT field in table propozycje. When I change query to: Code: 'SELECT * FROM propozycje'; Problem with MVC and passing the query data - El Forum - 06-24-2011 [eluser]osci[/eluser] sorry, didn't read carefully. disregard my last post. Code: $data['wynik'] = $this->Propozycje_model->get_search_results($pieniadze, $dla_kogo); Problem with MVC and passing the query data - El Forum - 06-24-2011 [eluser]michalo[/eluser] I change it. Now it gives me: Array to string conversion error in the same line: Code: $data['wynik'] = $this->propozycje_model->get_search_results($pieniadze, $dla_kogo); Problem with MVC and passing the query data - El Forum - 06-24-2011 [eluser]osci[/eluser] I believe where syntax is WHERE column_name operator value also you should check if query holds any data and then return ->result() Code: return ($query->num_rows() > 0) ? $query->result() : FALSE; and in your view you would do Code: if (isset($wynik) & ($wynik <> NULL)) Problem with MVC and passing the query data - El Forum - 06-24-2011 [eluser]michalo[/eluser] Thank's for good advice. When I manualy assign variables from form it works. I placed Code: $pieniadze=$_POST['pieniadze']; Code: extract($_POST); I have no idea why I can't use extract function but now it works fine. One more time thank you Problem with MVC and passing the query data - El Forum - 06-24-2011 [eluser]toopay[/eluser] *sigh. You can use my dbhelper, just to check if you already created the right query, then you can try to run it too. It will be like this Code: // in some controller function |