Using the data mapper pattern
If I have a User, and a UserMapper. Would I hash the password outside the class, set the hashed password on the User set method and then save the User with the UserMapper, or would I implement the Hash method to the User (data holder) class and then save with UserMapper. Or lastly, would I Hash in the save() method in the UserMapper? What is the correct way when implementing the Data mapper pattern?
Here's the User data holder:
class User implements UserInterface
{
protected $id;
public function __construct($row = null) {
if (!is_null($row)) {
$this->id = $row['id'];
}
}
public function setId($id) {
$this->id = $id;
}
public function getId() {
return $this->id;
}
链接地址: http://www.djcxy.com/p/56290.html
上一篇: Android中的文本/布局对齐(textAlignment,gravity)
下一篇: 使用数据映射器模式