title: Check if admin has logged in
body: <p>If there's someone logged in, this code checks the sessions and I can successfully view the page, but now I'd like to check if the user is admin. I tried checking in the model by Below is what I have tried and its not working. </p>
  
  <p>method that checks session and if its an admin</p>
  
  <pre><code>public function index()
  {
      $this-&gt;load-&gt;library('authlib');
      $loggedin = $this-&gt;authlib-&gt;is_loggedin();
      ///$admin = $this-&gt;auth-&gt;admin();
  
      if ($loggedin === false) {
      $this-&gt;load-&gt;helper('url');
      redirect('/auth/login');
      }
      if ($this-&gt;auth-&gt;admin() === false) {
      $message ['msg'] = "You are not an admin!";
      $this-&gt;load-&gt;view('homeview', $message);
      }
      else
      {
      $this-&gt;load-&gt;view('add_view');
      }
  }
  </code></pre>
  
  <p>Auth Controller</p>
  
  <pre><code>public function authenticate()
  {
  $username = $this-&gt;input-&gt;post('uname');
  $password = $this-&gt;input-&gt;post('pword');
  $user = $this-&gt;authlib-&gt;login($username,$password);
  **&gt;&gt; $this-&gt;admin($username,$password); &lt;&lt; passes the posted in values**
  if ($user !== false) {
      $this-&gt;load-&gt;view('homeview',array('name' =&gt; $user['name']));
  
  }
  else {
      $data['errmsg'] = 'Unable to login - please try again';
      $this-&gt;load-&gt;view('login_view',$data);
  }   
  }
  
  public function admin($username,$password){
  //$this-&gt;load-model('usermodel');
  $admin = $this-&gt;authlib-&gt;adminlib($username,$password);
  if ($admin == false){
  return false;
  //if ($res-&gt;num_rows() != 1){
  //return false;
  }
  }
  </code></pre>
  
  <p>library authlib</p>
  
  <pre><code>public function adminlib($user,$pwd) 
  {
  return $this-&gt;ci-&gt;usermodel-&gt;chkadmn($user,$pwd);
  }
  </code></pre>
  
  <p>the model</p>
  
  <pre><code>function chkadmn($username,$password)
  {
  $this-&gt;db-where(array('username' =&gt; $username,'password' =&gt; sha1($password)));
  $res = $this-&gt;db-&gt;get('users',array('type'));
  if ($res-&gt;num_rows() != 1) {
  return false;
  }
  }
  </code></pre>
  
  <p>Made some changes and now I get "Call to undefined function where() in C:\xampp\htdocs\ecwm604\application\models\usermodel.php on line 54"</p>