Suppose you are displaying a user's profile. It's good practice to store all database queries in the MODEL. I use this:
CONTROLLER:
$this->load->model('Profile');
$data['row'] = $this->Profile_model->profile_read(); //get profile data
$this->load->view('profile_view', $data); //load data to view
MODEL:
function profile_read()
{
$this->db->where('user_id', $user_id);
$query = $this->db->get('user_profiles'); //get all data from user_profiles table that belong to the respective user
return $query->row(); //return the data
}
In the model you can have all your other database functions (create, delete, update)
VIEW:
<?php echo $row->name; ?>
<?php echo $row->email; ?>
<?php echo $row->about; ?>
etc
Finally in the view you can echo any rows from the table that belong to the user.