Welcome Guest, Not a member yet? Register   Sign In
Trying to get property of non object
#1

[eluser]condoace[/eluser]
I am using the model method called content ($this->model_admin->content($limit, offset) to get data. I want to access each of the data from the model method individually inside the controller, but it gives me an error when trying to do it.

I am not sure if I am correctly accessing the object, e.g. $db4->first_name (is this correct or do I need a foreach loop first???)


CONTROLLER
Code:
function ajax_employees($offset = 0)
  {
  
   $this->load->model('model_admin');
  
   $this->load->library('Jquery_pagination');

   $config['base_url'] = site_url('admin/ajax_employees/');
  
   /* Here i am indicating to the url from where the pagination links and the table section will be fetched */

   $limit = 3;

   $config['div'] = '#content';
  
   /* CSS selector  for the AJAX content */
  
   $config['total_rows'] = $this->model_admin->num_rows();
  
   $config['per_page'] = $limit;
  
   $this->jquery_pagination->initialize($config);

   $this->load->library('table');
  
   $tmpl = array ( 'table_open'  => '<table border="0" cellpadding="2" cellspacing="1" width="100%" class="main_awesome_row">',
          
       'heading_cell_start'  => '<th class="main_awesome_header">',
                      
       'heading_cell_end'    => '</th>',

         );

   $this->table->set_template($tmpl);
  
   $this->table->set_heading('ID', 'First Name', 'Surname', 'Email','Other','Job Title','Department','Select');
  
   $db4 = $this->model_admin->content($limit, $offset);
  
   $list = array($db4->first_name, 'Select');

   $new_list = $this->table->make_columns($list, 8);
  
   $html = $this->table->generate($new_list).
   '<div align="center"><br/><span class="pagination">'.$this->jquery_pagination->create_links().'</span></div>';

   echo $html;
  
  }

MODEL


Code:
function num_rows() {
  
   return $this->db->count_all('employees');
  
  }

  function content( $limit, $offset ) {
  
    $this->db->select('id, first_name,last_name, email, other, job_title,department');
    
    $result = $this->db->get('employees', $limit, $offset);
    
    return $result->result_array();
}


Messages In This Thread
Trying to get property of non object - by El Forum - 11-14-2011, 01:46 AM



Theme © iAndrew 2016 - Forum software by © MyBB