protected function update($newDate, $rememberUser) { $arr = []; $params = []; if (isset($this->data['password'])) { $password = $this->data['password']; $password = password_hash($password, PASSWORD_DEFAULT); $this->data['password'] = $password; } foreach ($this->data as $key => $value) { $params[':' . $key] = $value; if ($key == 'id') { continue; } $arr[] = $key . ' = :' . $key; } if ($newDate) { $params[':date'] = date("Y-m-d H:i:s"); } $sql = "UPDATE "; $sql .= static::$table; $sql .= " SET "; $sql .= implode(', ', $arr); $sql .= " WHERE id = :id "; $sql .= "LIMIT 1"; $db = new DB(); $result = $db->execute($sql, $params); if ($result) { if ($rememberUser) { // Вход с помощью сессии // $user = self::getByColumn('email', $this->data['email']); // Session::createSession('user', $user); // Вход с помощью cookie $key = 'avtobus12troleibus23h23'; $encrypted = FL::encrypted($this->data['email'], $key); setcookie('user', $encrypted, 0x7fffffff, '/'); } return $result; } else { throw new ModelException('Произошла ошибка при редактировании'); } }