File manager - Edit - /home/webapp69.cm.in.th/u69319090028/Shop/app/Models/UserAgreementAcceptance.php
Back
<?php /** * UserAgreementAcceptance Model * Maps to `user_agreement_acceptances` table */ require_once __DIR__ . '/../Core/Model.php'; class UserAgreementAcceptance extends Model { protected string $table = 'user_agreement_acceptances'; public function getAcceptancesByAgreement(int $agreementId, int $limit = 50, int $offset = 0): array { $sql = "SELECT uaa.*, u.username, u.email, u.first_name, u.last_name FROM `user_agreement_acceptances` uaa JOIN `users` u ON uaa.user_id = u.id WHERE uaa.agreement_id = :aid ORDER BY uaa.accepted_at DESC LIMIT :limit OFFSET :offset"; $stmt = $this->db->prepare($sql); $stmt->bindValue(':aid', $agreementId, PDO::PARAM_INT); $stmt->bindValue(':limit', $limit, PDO::PARAM_INT); $stmt->bindValue(':offset', $offset, PDO::PARAM_INT); $stmt->execute(); return $stmt->fetchAll(); } public function countAcceptances(int $agreementId): int { $sql = "SELECT COUNT(*) FROM `user_agreement_acceptances` WHERE agreement_id = :aid"; $stmt = $this->query($sql, [':aid' => $agreementId]); return (int)$stmt->fetchColumn(); } public function hasUserAcceptedLatest(int $userId, string $type, string $latestVersion): bool { $sql = "SELECT id FROM `user_agreement_acceptances` WHERE user_id = :uid AND agreement_type = :type AND version = :ver LIMIT 1"; return (bool)$this->fetchOne($sql, [ ':uid' => $userId, ':type' => $type, ':ver' => $latestVersion ]); } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.25 |
proxy
|
phpinfo
|
Settings