[eluser]Andeh17[/eluser]
[quote author="PhilTem" date="1328196906"]I prefer
Code:
function is_admin($username)
{
return $this->db
->from('users')
->where('username', $username)
->where('is_admin', '1')
->count_all_results() == 1;
}
because it's much shorter (if you compress code) and you actually don't run a real select query but more a 'SELECT COUNT(*) FROM' query. Which is a little fail safer for sql-injections since it only returns a number and no full rows.
But both queries are right. I like mine just a little more since it only counts matches and doesn't select them
Refer to CI user's guide -> database class -> active record.[/quote]
But that still doesn't fix why i'm receiving..
Fatal error: Call to undefined method CI_Loader::is_admin() in /Applications/XAMPP/xamppfiles/htdocs/codeigniter/application/views/logged_in_area.php on line 15
What is on that line:
if($this->is_admin($this->session->userdata('username')))
Cheers anyway.