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?
#2

[eluser]InsiteFX[/eluser]
Why dont you use the benchmarking and figure it out for yourself?

InsiteFX
#3

[eluser]Wondering Coder[/eluser]
haha, thanks InsiteFX. didn't know about benchmarking but now I do.




Theme © iAndrew 2016 - Forum software by © MyBB