Welcome Guest, Not a member yet? Register   Sign In
How to get data objects in controller
#1

I'm really new to this so excuse my query on something that is probably fundamental but...

I have a controller that has the model in the constructor, I have created a method in the model which grabs a record from the database.
I call it in my controller like so:

$data['user'] = $this->jobseekers_model->getUser($userId);

Now I have checked and it is returning an array, I can see it using print_r but I can't seem to figure out how to get an array element, I am trying to set a session var using:

$newdata = array(
        'username'  => $user['username'],
        'email'     => $user['email'],
        'logged_in' => TRUE
        );

 but then I get the error:
Message: Undefined variable: user

can anyone please advise?
Do I need to loop through the array first an assign each array element to a new array? Surely not?
Reply


Messages In This Thread
How to get data objects in controller - by barrypoore - 04-09-2018, 05:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB