[eluser]jshultz[/eluser]
I'm not sure why this is happening. I'm trying to retrieve data from a table in a mysql db. one way it works, but the other way it doesn't. And when it doesn't work, all I get is white screen with no error messages.
Here's how it definitely works:
If i place the query in the site controller I have no problems.
Code:
function project_list()
{
if (!$this->tank_auth->is_logged_in()) {
redirect('/auth/login/');
} else {
$data['query'] = $this->db->get('projects');
$data['user_id'] = $this->tank_auth->get_user_id();
$data['username'] = $this->tank_auth->get_username();
$this->load->view('header', $data);
$this->load->view('menu');
$this->load->view('sidebar', $data);
$this->load->view('project-list-view', $data);
$this->load->view('footer');
}
}
I never use the model and instead in project-list-view i have this code:
Code:
<div id="content" class="span-16 last">
<h1>We Get You Noticed!</h1>
<?php foreach($query->result() as $row): ?>
<h3><?=$row->project_name?></h3>
<p><?=$row->due_date?></p>
<?php endforeach; ?>
</div>
And everything works just fine. However, if I instead the project_model model like so:
Code:
class Project_model extends Model {
function getAll() {
$q = $this->db->get('projects');
if($q->num_rows() > 0) {
foreach ($q->result() as $row) {
$data[] = $row;
}
return $data;
}
and in site.php the only changes I make is to remove this:
$data['query'] = $this->db->get('projects');
and replace it with this:
Code:
$this->load->model('Project_model');
$data['rows'] = $this->Project_model->getAll();
then the view fails to load and all I get is the white screen.
I'm still just learning so i'm probably missing something obvious but i've been watching video after video over and over and reading all i can find. If I was at least getting some kind of error message that'd be nice but i'm not. So, it's come down to trial and error to see what works. Which isn't bad of course, but it does suck up a lot of time.