Welcome Guest, Not a member yet? Register   Sign In
Accessing associative arrays from models
#1

[eluser]condoace[/eluser]
I want to grab some data from a model and pass it to a controller. How do I turn the $query variable in my controller into a set of independant variables so I can pass them to another method etc.. here is my code thus far:

I want the variable $my_id to store the id value from the model.

CONTROLLER
Code:
$this->load->model('Model_employees');
  
   $query = $this->Model_employees->validate_user();
  
   $my_id = $query->id;
  
   if($query == true) // if the user's credentials validated...
   {
    $data = array(
    
     'user_id' => $my_id,
    
     'login_email' => $this->input->post('login_email'),
    
     'logged_in' => true
    );
    
    $this->session->set_userdata($data);
    
    redirect('employees/index');
   }
   else // incorrect username or password
   {
    echo 'not working';
   }

MODEL

Code:
function get_my_credits($id) {
  
   $query = "SELECT * FROM credit_history WHERE id = '".$id."' ";
  
   $result = $this->db->query($query);
  
   return $result->result();
    
  }




Theme © iAndrew 2016 - Forum software by © MyBB