mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-05-29 01:49:51 +02:00
some fixes on comments
This commit is contained in:
parent
a2c33a4c58
commit
2ca016fb66
DataMapper
@ -10,18 +10,18 @@ namespace DesignPatterns;
|
||||
|
||||
$userMapper = new UserMapper();
|
||||
|
||||
// fetch a record from Database
|
||||
/* fetch a record from Database */
|
||||
$user = $userMapper->findById(1);
|
||||
|
||||
if ($user !== null) {
|
||||
echo "Hello " . $user->getUsername() . ". Your email is " . $user->getEmail();
|
||||
}
|
||||
|
||||
// save a new record on Database
|
||||
/* save a new record on Database */
|
||||
var $newUser = new User('', 'Odysseus', 'Odysseus@ithaca.gr');
|
||||
$userMapper->save($newUser);
|
||||
|
||||
// fetch all from a table on Database
|
||||
/* fetch all from a table on Database */
|
||||
var $user = $userMapper->findAll();
|
||||
|
||||
?>
|
@ -43,14 +43,14 @@ class UserMapper
|
||||
*/
|
||||
public function save(User $user)
|
||||
{
|
||||
// $data keys shoulds correspond to valid Table columns on the Database
|
||||
/* $data keys shoulds correspond to valid Table columns on the Database */
|
||||
$data = array(
|
||||
'userid' => $user->getUserId(),
|
||||
'username' => $user->getUsername(),
|
||||
'email' => $user->getEmail(),
|
||||
);
|
||||
|
||||
// if no ID specified create new user else update the one in the Database
|
||||
/* if no ID specified create new user else update the one in the Database */
|
||||
if (null === ($id = $user->getUserId())) {
|
||||
unset($data['userid']);
|
||||
$this->_adapter->insert($data);
|
||||
|
Loading…
x
Reference in New Issue
Block a user