Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter App getting data from the wrong mySQL table?
#1

[eluser]Dave Blencowe[/eluser]
Hey,

Recently I have been coding the Blog section to my personal site which is based on Codeigniter and have run across a problem.
I have made a model for getting things like posts etc from the database and then have the controller use the model to get the appropriate results yet when I ask for data from one table for comments it returns another table altogether and I just can't see why.

The section of the model
Code:
function get_blog($id, $limit = NULL)
    {
        
        $this->db->order_by("id", "desc");
        if($limit !== NULL)
        {
            $this->db->limit($limit);
        }
        
        if($id)
        {
            $this->db->where('id', $id);
        }
        $blog = $this->db->get('content_blog');
        return $blog->row_array();
    }
    
    function get_comments($id)
    {
        $this->db->order_by('id', 'desc');
        $this->db->where('post_id', $id);
        $comments = $this->db->get('content_test');
        return $comments->row_array();
    }

The section of the controller
Code:
function comments()
    {
        $this->load->view('template/default/header');
        
        $id = $this->uri->segment(3);    
        $get_blog = $this->mdl_blog->get_blog($id, '1');        

        $get_comments = $this->mdl_blog->get_comments($id, NULL);

        $this->load->view('blog/comments/main_view', $get_blog);
        $this->load->view('blog/comments/comments_view', $get_comments);
        $this->load->view('blog/comments/comments_add');
        $this->load->view('template/default/footer');
    }

These two views seem to have the the $get_blogs variable passed to them each time...
Code:
$this->load->view('blog/comments/main_view', $get_blog);
        $this->load->view('blog/comments/comments_view', $get_comments);


I've attached the files in case they are any use and I thank you for any help you might be able to provide.

Thanks,
Dave


Messages In This Thread
CodeIgniter App getting data from the wrong mySQL table? - by El Forum - 10-07-2008, 02:13 AM



Theme © iAndrew 2016 - Forum software by © MyBB