Welcome Guest, Not a member yet? Register   Sign In
am i doing this the most efficent way
#1

[eluser]tim1965[/eluser]
Hi new to ci and PHP, so would appreciate soemone looking at my code to see if i am doing this the best way. I am using DX_auth (which is great) for my authentication. Just after login i need to grab the username and then query a table for the property id (1 per user).
Once i retrieve this i need to add this to the custom session info. This seems to be working ok. My question is if there is a more efficent way of doing this than i have coded below, as it seems to me to be quite clunky. I am just trying to get into best practice as early as possible given this my first app build using CI. Thanks in advance.

// This event occurs right after user login
function user_logged_in($user_id)
{
//run dx_auth function to get username
$uname = $this->ci->dx_auth->get_username('username');
//query my table to get propery_id using username
$this->ci->db->where('username',$uname);
$this->ci->db->select('property_id');
$query = $this->ci->db->get('master_property_reference');
$row = $query->row();
//add to ci_session database for use in each page
$add_prop_id = array(
'propertyid' => $row->query ,
);
$this->ci->session->set_userdata($add_prop_id);

}




Theme © iAndrew 2016 - Forum software by © MyBB