Empty database output in CI

Posted by den-javamaniac on Stack Overflow See other posts from Stack Overflow or by den-javamaniac
Published on 2010-05-08T13:04:24Z Indexed on 2010/05/08 13:08 UTC
Read the original article Hit count: 121

Filed under:
|
|

Hi. I'm building a simple app and trying to test DB result output. But unfortunately all I'm getting is an array of size 0. Here's the controller code excerpt:

$data['query'] = $this->db->query('SELECT role_id, role_privilege FROM role');
$this->load->view('welcome_message', $data);

And a view code excerpt:

<?php
        echo count($query->result_array())."<br/>";
        foreach ($query->result() as $row){
            echo $row->role_id . '<br/>';
            echo $row->role_privilege . '<br/>';
        }
        echo 'Total result '.$query->num_rows();
    ?>

And what I get is next:

0
Total result

Running query from a command line gives a 2 rowed output. Can someone point out what i'm missing?

© Stack Overflow or respective owner

Related posts about web-development

Related posts about php