Skip to content

Instantly share code, notes, and snippets.

@rashivkp
Created January 10, 2014 16:37
Show Gist options
  • Save rashivkp/8357633 to your computer and use it in GitHub Desktop.
Save rashivkp/8357633 to your computer and use it in GitHub Desktop.
<?php
class User_model extends CI_Model {
function __construct()
{
parent::__construct();
}
/**
* authenticate user login
*
* @return bool
*/
function authenticate($username, $password) {
$this->db->select('1', True);
$this->db->where('username', $username);
$this->db->where('password', $password);
$q = $this->db->get('user');
return $q->num_rows()===1;
}
/**
* return all users
*/
function users($username = False) {
if($username) {
$this->db->where('username', $username);
}
$q = $this->db->get('user');
return $q->result();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment