Created
January 15, 2012 11:54
-
-
Save phawk/1615596 to your computer and use it in GitHub Desktop.
This file contains 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 Model { | |
function add_user($user_array) | |
{ | |
// Insert the new user array into the users table | |
return $this->db->insert('users',$user_array); | |
} | |
function auth_user($email,$password) | |
{ | |
// Select the following fields | |
$this->db->select('id, email, password'); | |
// From the users table | |
$this->db->from('users'); | |
// Where email address and password match the params we passed into the function. | |
$this->db->where('email',$email); | |
$this->db->where('password',$password); | |
// Get the results | |
$query = $this->db->get(); | |
// There should be only 1 row. | |
if($query->num_rows() === 1) | |
{ | |
$row = $query->row(); | |
// Return the users id. | |
return $row->id; | |
} | |
else | |
{ | |
return false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment