From: Christian Weiske Date: Mon, 29 Apr 2024 18:17:47 +0000 (+0200) Subject: Add updated_at column to accounts X-Git-Url: https://git.cweiske.de/gamestick-pjgsapi.git/commitdiff_plain/HEAD?ds=sidebyside Add updated_at column to accounts --- diff --git a/src/Profile.php b/src/Profile.php index e120546..bf6ddb9 100644 --- a/src/Profile.php +++ b/src/Profile.php @@ -17,6 +17,7 @@ class Profile public ?string $avatar; public string $created_at; + public string $updated_at; public function __construct() { diff --git a/src/ProfileDb.php b/src/ProfileDb.php index 29f3eda..924435d 100644 --- a/src/ProfileDb.php +++ b/src/ProfileDb.php @@ -59,8 +59,8 @@ class ProfileDb $stmt = $this->db->prepare( <<execute( @@ -68,6 +68,8 @@ SQL ':hwId' => $hwId, ':sessionId' => 's' . str_replace(':', '', $hwId), ':verificationCode' => date('His'), + ':created_at' => date('c'), + ':updated_at' => date('c'), ] ); return $this->getProfileByHardwareId($hwId); @@ -76,11 +78,14 @@ SQL public function updateProfile(string $hwId, array $values): ?Profile { $params = [ - 'hwId' => $hwId, + ':hwId' => $hwId, + ':updated_at' => date('c'), ]; $sql = 'UPDATE gamesticks SET'; - $sqlParts = []; + $sqlParts = [ + ' updated_at = :updated_at' + ]; foreach ($values as $column => $value) { $sqlParts[] = ' ' . $column . '= :' . $column; $params[':' . $column] = $value; @@ -115,7 +120,8 @@ SQL minAge INTEGER DEFAULT 3 NOT NULL, avatar TEXT DEFAULT NULL, - created_at TEXT DEFAULT CURRENT_TIMESTAMP + created_at TEXT DEFAULT CURRENT_TIMESTAMP, + updated_at TEXT DEFAULT CURRENT_TIMESTAMP ) SQL );