Ответов: 3 Просмотров: 54
|
PHP:
скопировать код в буфер обмена
<?PHP //Подключился к БД require_once 'DB.php'; class User { public $id; public $username; public $hashedPassword; public $email; public $skype; public $joinDate; function __construct($data) { $this->id = (isset($data['id'])) ? $data['id'] : ""; $this->username = (isset($data['username'])) ? $data['username'] : ""; $this->hashedPassword = (isset($data['password'])) ? $data['password'] : ""; $this->email = (isset($data['email'])) ? $data['email'] : ""; $this->skype = (isset($data['skype'])) ? $data['skype'] : ""; $this->joinDate = (isset($data['join_date'])) ? $data['join_date'] : ""; } public function save($isNewUser = false) { $db = new DB(); if(!$isNewUser) { //Забыл сюда внести изменения "username" => "'$this->username'", "password" => "'$this->hashedPassword'", "email" => "'$this->email'", "skype" => "'$this->skype'" ); $db->update($data, 'users', 'id = '.$this->id); }else { "username" => "'$this->username'", "password" => "'$this->hashedPassword'", "email" => "'$this->email'", "join_date" => "'".date("Y-m-d H:i:s",time())."'" ); $this->id = $db->insert($data, 'users'); $this->joinDate = time(); } return true; } } ?>
|