Skip to content

Instantly share code, notes, and snippets.

@phawk
Created January 15, 2012 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phawk/1615596 to your computer and use it in GitHub Desktop.
Save phawk/1615596 to your computer and use it in GitHub Desktop.
<?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