- sogoctl: supervisor avec health checks et restart auto - sogoway: gateway HTTP, auth JWT, routing par hostname - sogoms-db: microservice MariaDB avec pool par application - Protocol IPC Unix socket JSON length-prefixed - Config YAML multi-application (prokov) - Deploy script pour container Alpine gw3 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
75 lines
1.7 KiB
PHP
75 lines
1.7 KiB
PHP
<?php
|
|
/**
|
|
* Modèle User
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
class User
|
|
{
|
|
public static function findById(int $id): ?array
|
|
{
|
|
$db = Database::getInstance();
|
|
|
|
$stmt = $db->prepare('
|
|
SELECT id, email, name, created_at, updated_at
|
|
FROM users
|
|
WHERE id = :id
|
|
');
|
|
|
|
$stmt->execute(['id' => $id]);
|
|
$user = $stmt->fetch();
|
|
|
|
return $user ?: null;
|
|
}
|
|
|
|
public static function findByEmail(string $email): ?array
|
|
{
|
|
$db = Database::getInstance();
|
|
|
|
$stmt = $db->prepare('
|
|
SELECT id, email, name, password, created_at, updated_at
|
|
FROM users
|
|
WHERE email = :email
|
|
');
|
|
|
|
$stmt->execute(['email' => $email]);
|
|
$user = $stmt->fetch();
|
|
|
|
return $user ?: null;
|
|
}
|
|
|
|
public static function update(int $id, array $data): bool
|
|
{
|
|
$db = Database::getInstance();
|
|
|
|
$fields = [];
|
|
$params = ['id' => $id];
|
|
|
|
if (isset($data['name'])) {
|
|
$fields[] = 'name = :name';
|
|
$params['name'] = $data['name'];
|
|
}
|
|
|
|
if (isset($data['email'])) {
|
|
$fields[] = 'email = :email';
|
|
$params['email'] = $data['email'];
|
|
}
|
|
|
|
if (isset($data['password'])) {
|
|
$fields[] = 'password = :password';
|
|
$params['password'] = password_hash($data['password'], PASSWORD_DEFAULT);
|
|
}
|
|
|
|
if (empty($fields)) {
|
|
return false;
|
|
}
|
|
|
|
$sql = 'UPDATE users SET ' . implode(', ', $fields) . ' WHERE id = :id';
|
|
$stmt = $db->prepare($sql);
|
|
$stmt->execute($params);
|
|
|
|
return $stmt->rowCount() > 0;
|
|
}
|
|
}
|