Welcome Guest, Not a member yet? Register   Sign In
Which method is faster?
#1

[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?


Messages In This Thread
Which method is faster? - by El Forum - 07-24-2011, 08:45 PM
Which method is faster? - by El Forum - 07-24-2011, 09:55 PM
Which method is faster? - by El Forum - 07-26-2011, 02:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB