[eluser]Wondering Coder[/eluser]
good morning,
Just want to ask a quick question to which is the best way for this..
Code:
First method
function Admin()
{
.......
$user_id = $this->session->userdata('ad_userid');
$cond = array('ad_userid' => $user_id);
$data['admin_profile'] = $this->admin_db->getAdmin($cond)->row();
.....
}
Code:
2nd method
function Admin()
{
.......
$cond = array('ad_userid' => $this->userid()); //get the data from MY_Controller
$data['admin_profile'] = $this->admin_db->getAdmin($cond)->row();
.....
}
MY_Controller
{
...
public function userid()
{
$userid = $this->session->userdata('user_id');
if(!empty($userid)){
$cond = $userid;
}
else{
$cond = $this->session->userdata('ad_userid');
}
return $cond;
}
}
Does using extended classes and accessing its function put a lot memory usage?