<?php
declare(strict_types=1);

class DbHelper
{
    public static function tableExists(PDO $db, string $table): bool
    {
        $stmt = $db->prepare(
            'SELECT 1 
             FROM information_schema.tables 
             WHERE table_schema = DATABASE()
               AND table_name = :table'
        );
        $stmt->execute(['table' => $table]);
        return (bool) $stmt->fetchColumn();
    }

    public static function count(PDO $db, string $sql, array $params = []): int
    {
        $stmt = $db->prepare($sql);
        $stmt->execute($params);
        return (int) $stmt->fetchColumn();
    }
}
