[eluser]avramovic[/eluser]
Ok, first of all, I am new with CI, and I have looked at documentation but haven't found answer to my question: I am using function "getusernamefromid" because I have ID of user stored in database table, and I need username of that user very often. The function is something like this:
Code:
function getuserfromid($id) {
$this->db->where('id',$id);
$query = $this->db->get('users',1);
$row = $query->result();
return $row[0]->username;
}
Now, this helper functions are usually defined as functions in helper files, but every helper I saw is NOT using database. I need to connect to database and get username, and when I place this code in helper file (and load helper) it says that I can not use that (function
getuserfromid is not defined in class so I can't use $this)... so... how can I achieve this?