Welcome Guest, Not a member yet? Register   Sign In
Models not working
#1

[eluser]Kurai[/eluser]
Now I feel really stupid.
I've created a simple database for a very basic blog application. Then I've put some data in the only table (blog_posts) I've got through the scaffolding feature. Then I built up a very basic controller with a "die" statement for testing purposes, and consequently a model which fetches data from the db and then passes them to the controller.

The thing is, controller is working as long as I don't load the model. When I do this, trying to fetch data, all I've got is a blank page. The code is very simple, and I can't understend where the error is. Here's my model:
Code:
<?php
class Blogmodel extends Model{
    
    function Blogmodel{
        parent::Model();
    }
    
    function get_posts(){

        $query = $this->db->get('blog_posts');
        return = $query->result();
    }
    
}

?>

and then the controller:
Code:
<?php
class blog extends Controller{
    
    function Blog(){
        parent::Controller();
        $this->load->model('Blogmodel', 'blog', true);
    }
    function index(){
        
        $data['title'] = "Titolo del blog";
        $data['heading'] = "Primo Blog";
        $data['query'] = $this->blog->get_posts();
        die (print_r($data));
    }
    
}
?>


Probably there's something very stupid I can't get...


Messages In This Thread
Models not working - by El Forum - 01-11-2008, 07:13 AM
Models not working - by El Forum - 01-11-2008, 08:16 AM
Models not working - by El Forum - 01-11-2008, 08:25 AM
Models not working - by El Forum - 01-11-2008, 08:36 AM
Models not working - by El Forum - 01-11-2008, 11:27 AM
Models not working - by El Forum - 01-11-2008, 03:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB