I have the following code that confirms a activation with the database. What I am wanting to no now is what is the best method to enable me so extract the users first name userFirstName that is linked to the specific activation code? and how would I pass it as $data['userFirstName'] = What into the controller.
Model:
function confirmUser($activateCode)
{
if($activateCode == '')
{
return FALSE;
}
//Selects the userID where the given URI activateCode = ?
$this->db->select('userID');
$this->db->from('users');
$this->db->where('userActiveCode', $activateCode);
$result = $this->db->get();
if($result->num_rows == 1) // If the above result is = 1 then update the userActive row else it will fail
{
$this->db->set('userActive', 1);
$this->db->where('userActiveCode', $activateCode);
$this->db->update('users');
return TRUE;
}else{
return FALSE;
}
}
You can also use a reference parameter to your model method to return the user’s first name to the caller. This would allow a clean boolean return value.
Model
Caller
When passing-by-reference, as opposed to passing-by-value, you are essentially passing a pointer (memory address) to the spot in memory that holds the value rather than the actual value; therefore, when you change the value in the method, the parameter that was passed-by-reference by the caller also changes. This is because they are both pointing to the same exact memory address.