[eluser]cyberjunkie[/eluser]
I'm having some trouble with active record. I have 2 database tables. One named
users that retrieves general user data such as name, email, etc and table
user_links that retrieves links that the respective user submitted.
I'm trying to return both general info and links in 1 page. I'm using the following code
Model:
Code:
$this->db->select('*');
$this->db->from('users');
$this->db->join('user_links', "user_links.user_id = users.user_id"); //get links for respective user
$this->db->where('users.user_id', $user_id);
$this->db->where('user_links.user_id', $user_id);
$query = $this->db->get();
return $query->row();
Controller:
Code:
$this->load->model('User_model');
$data['row'] = $this->User_model->user_read($user_id); //$user_id is third URL segment
$this->load->view('profile/user_view', $data);
View:
Code:
<?php echo $row->first_name; ?>
<?php echo $row->last_name; ?>
etc...
With the where() function in the model I get
Code:
Trying to get property of non-object
Without it works but it's returning the first row in the database. I need the where clause. Can someone please tell me what I'm doing wrong?