Welcome Guest, Not a member yet? Register   Sign In
Problem in generating query
#11

[eluser]-spy-[/eluser]
in my first attempt, i did'nt use the model, i made my query inside the controller, but the same error happened.. yes i have my file student.php..inside the model folder..

application/controllers/profile.php
application/model/student.php
#12

[eluser]gtech[/eluser]
what does your controller and model look like now when you put the changes in.. has the error message changed, since you put michaels changes in?
#13

[eluser]-spy-[/eluser]
this is weird, i can now generate the query, and retrieve data from the database, i tried again to put my query inside the controller, it's now working.. but unfortunately i can't make it in the model...

Fatal error: Call to a member function result() on a non-object in D:\Program Files\xampp\htdocs\pupcomm\system\application\views\profile\history.php on line 44

here's my code in profile.php
Code:
<?php
class Profile extends Controller {

    function Profile()
    {
        parent::Controller();    
    }
    
    function history()
    {
        $this->load->model('Student');
        $data['query'] = $this->Student->view_list();
        //$data['query'] = $this->db->query("SELECT * FROM SAMPLE_RECORDLIST");
        $this->load->view('profile/history', $data);    
    }
}
?>


here's my code in student.php
Code:
<?php
class Student extends Model {

    function Student()
    {
        parent::Model();
    }
    
    function view_list()
    {
        $query = $this->db->get('sample_recordlist');
        return $query->result();
    }
}
?>

hope you can help me again...
#14

[eluser]Armchair Samurai[/eluser]
It sounds as if you're trying to call $query->result() from your view, which won't work.

When iterating through the array passed by your model, just do a simple loop rather than calling result() which is meaningless to the system unless called by the database layer:
Code:
/**
* In the view history.php
*/

foreach ($query as $val)
{
    // Do something here - for example:
    echo "$val->foo<br />
        $val->bar<br />";
}
#15

[eluser]-spy-[/eluser]
this is weird again..it's now working..but i did'nt change anything.. tnx for the help guys n_n
#16

[eluser]-spy-[/eluser]
it's not working again...i did'nt change anything..
#17

[eluser]metaltapimenye[/eluser]
is that all the contain of the scripts?..i bet it must be we just miss a tiny stuff to make it work out. mind to show the whole MVC scripts? whats wrong with line 11?
#18

[eluser]-spy-[/eluser]
ok... i think i can now manage this... thanks again for the help...n_n




Theme © iAndrew 2016 - Forum software by © MyBB