Skip to content

Instantly share code, notes, and snippets.

Created December 3, 2009 05:44
Show Gist options
  • Save anonymous/247922 to your computer and use it in GitHub Desktop.
Save anonymous/247922 to your computer and use it in GitHub Desktop.
class Contact_Model extends Model
{
public function read_contact($contact_id)
{
if(is_numeric($contact_id))
{
$db = new Database;
$query = $db->query("
select
id,
firstname,
lastname,
phone,
email
from
contacts
where
id = $contact_id
");
}
else throw new Exception('Not a valid contact ID');
if($query->count())
{
return $query->current();
}
else throw new Exception('Contact not found.');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment