I'm trying to build VERY basic model->controller->view structure with CodeIgniter. I'd rather use models (and model functions, more importantly) and controllers than executing queries within each view.
First off, here's the model:
class Leads extends Model {
function Leads()
{
parent::Model();
}
function fetch_leads()
{
$query = $this->db->get('leads', 10);
return $query->result();
}
}
Here's the controller, only relevant function being the one in question:
function view()
{
$this->load->model('Leads', '', TRUE);
$data['query'] = $this->Leads->fetch_leads();
$this->load->view('html_head');
$this->load->view('leads/view', $data);
$this->load->view('html_foot');
}
I think the problem is in this line, I may not be passing the data to the view correctly:
$data['query'] = $this->Leads->fetch_leads();
Now, the view:
print_r $data;
Did I mention basic? I'm just trying to get it to pull every field and print it from the database. Yes, the database is configured correctly, and yes, there is data in the database.
EDIT: The model wasn't auto-connecting to the database, so I added that parameter. The model still isn't returning values.