12]); $now = date('Y-m-d H:i:s'); $stmt = $pdo->prepare('SELECT id FROM users WHERE email = :email LIMIT 1'); $stmt->execute(['email' => $email]); $id = $stmt->fetchColumn(); if ($id) { $pdo->prepare( 'UPDATE users SET password_hash = :h, role = :role, admin_level = :level, status = :status WHERE id = :id' )->execute([ 'h' => $hash, 'role' => 'admin', 'level' => 'full', 'status' => 'active', 'id' => (int)$id, ]); fwrite(STDOUT, "OK updated admin #{$id} {$email}\n"); exit(0); } $pdo->prepare( 'INSERT INTO users (email, password_hash, role, admin_level, status, created_at) ' . 'VALUES (:email, :h, :role, :level, :status, :created_at)' )->execute([ 'email' => $email, 'h' => $hash, 'role' => 'admin', 'level' => 'full', 'status' => 'active', 'created_at' => $now, ]); fwrite(STDOUT, "OK created admin {$email}\n");