Created
December 3, 2009 05:44
-
-
Save anonymous/247922 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
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, | |
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