• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
missing data from database query

#1
[eluser]richzilla[/eluser]
Hi all. Im having a few problems retrieving data from an mysql database. According to the Codeigniter documentation the result() method reuturnsa an array of objects, so in my example, this function from my model should return an array of objects.

Code:
function get_client_issues($id)
    {
        $this->db->where('issueClientId',$id);
        $query = $this->db->get('issues');
        
        if ($query->num_rows() > 0)
        {
            return $query->result();
        }
        else
        {
            return FALSE;
        }
    }

however when i try to access this array in the controller with this method:

Code:
function Index()
    {
        $res = $this->issue_model->get_client_issues($this->session->userdata('userid'));
        if ($res != FALSE)
        {
            $this->_show('clients/clients_view', $res);
        }
        else
        {
            $this->_show('clients/clients_view');
        }
        
    }

i get an error from the view that calls this, saying that im trying to get the property of a non object. I cant see anywhere that could be causing any problems, however i wondered if anyoen else could spot where ive gone wrong. Just to fill in the blanks, the part of the view thats raising the error is:

Code:
<?php foreach ($data as $issue) : ?>
                
                        <tr>
                        <td class="wide">&lt;?php echo $issue->issueId; ?&gt;</td>
                        <td class="wide">&lt;?php echo $issue->issueOpened; ?&gt;</td>

                        </tr>
                    &lt;? endforeach; ?&gt;

and my _show method:

Code:
function _show($page, $data)
    {
        $this->load->view('global_header');
        $this->load->view($page, $data['data']);
        $this->load->view('global_footer');
    }

any help would be appreciates. Thanks

#2
[eluser]n0xie[/eluser]
Code:
function _show($page, $result)
    {
        $data['data'] = $result;
        $this->load->view('global_header');
        $this->load->view($page, $data);
        $this->load->view('global_footer');
    }
Try this


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.