Created
January 10, 2014 16:37
-
-
Save rashivkp/8357633 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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