Created
February 9, 2013 11:43
-
-
Save coreymcmahon/4744983 to your computer and use it in GitHub Desktop.
Our User model, version 2.0. From the article: PDO for Elegant PHP Database Access, http://www.modernphpbook.com/articles/pdo-for-elegant-php-database-access - Fig 11
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 | |
{ | |
public $id; | |
public $username; | |
public $firstname; | |
public $lastname; | |
public $email; | |
public function __construct($data = null) | |
{ | |
if (is_array($data)) { | |
if (isset($data['id'])) $this->id = $data['id']; | |
$this->username = $data['username']; | |
$this->firstname = $data['firstname']; | |
$this->lastname = $data['lastname']; | |
$this->email = $data['email']; | |
} | |
} | |
public function getFullname() | |
{ | |
echo $this->firstname . ' ' . $this->lastname; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment