Welcome Guest, Not a member yet? Register   Sign In
Num_rows Error
#1

[eluser]Arasoi[/eluser]
Ok folks, I have poked around for a bit know and can not seem to find a post helping me with my issue. Now I know it is something retarded I have done but baring that in mind it is what also makes me unable to see it Smile

I get this error :
Code:
Fatal error: Call to a member function num_rows() on a non-object

From this code :
Code:
function con_getfieldchecks($Start,$PageSize,$EID = NULL)
    {
        $this->load->database('default', TRUE);

        if($EID == NULL){
        // Load the total number of rows in the table
            $this->db->select();
            $query = $this->db->get('fc_AddressRequests');
            $output['totalCount'] = $query->num_rows();
        // now retrive just the first page of data from that table
            $this->db->select();
            $this->db->where('A.rownum BETWEEN ('. $Start .') AND ('. $Start .'+'. $PageSize .' )');
            $query = $this->db->get('(SELECT row_number() OVER (ORDER BY RequestDate) AS rownum, * FROM   fc_AddressRequests_View) AS A');
            $output['records'] = $query->result_array();
        }else{
        // Load the total number of rows in the table matching the EID
            $this->db->select();
            $this->db->where('EID', $EID);
            $query = $this->db->get('fc_AddressRequests');
            $output['totalCount'] = $query->num_rows();
        // now retrive just the first page of data from that table matching the EID    
            $this->db->where('A.rownum BETWEEN ('. $Start .') AND ('. $Start .'+'. $PageSize .' )');
            $this->db->where('EID', $EID);
            $query = $this->db->get('(SELECT row_number() OVER (ORDER BY RequestDate) AS rownum, * FROM   fc_AddressRequests_View) AS A');
            $output['records'] = $query->result_array();
        }
        // Convert the array into JSON format and return it
        return json_encode($output);

    }


If I comment out the
Code:
$output['totalCount'] = $query->num_rows();
all works fine. but I do need the total rows returned in order for paging to work right on the tables I use. Big thanks from the start to all the help Smile


Messages In This Thread
Num_rows Error - by El Forum - 12-03-2009, 11:12 AM
Num_rows Error - by El Forum - 12-03-2009, 12:27 PM
Num_rows Error - by El Forum - 12-03-2009, 01:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB