File manager - Edit - /home/webapp69.cm.in.th/u69319090028/Shop/app/Models/LoginHistory.php
Back
<?php /** * LoginHistory Model * Maps to `login_history` table */ require_once __DIR__ . '/../Core/Model.php'; class LoginHistory extends Model { protected string $table = 'login_history'; public function record(int $userId, string $status, ?string $ip = null, ?string $userAgent = null): void { $this->insert([ 'user_id' => $userId, 'ip_address' => $ip ?? Security::getClientIp(), 'user_agent' => $userAgent ?? Security::getUserAgent(), 'status' => $status, 'created_at' => date('Y-m-d H:i:s') ]); } public function getByUserId(int $userId, int $limit = 20): array { $sql = "SELECT * FROM `login_history` WHERE `user_id` = :user_id ORDER BY `created_at` DESC LIMIT :limit"; $stmt = $this->db->prepare($sql); $stmt->bindValue(':user_id', $userId, PDO::PARAM_INT); $stmt->bindValue(':limit', $limit, PDO::PARAM_INT); $stmt->execute(); return $stmt->fetchAll(); } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.23 |
proxy
|
phpinfo
|
Settings