public static function count($tableNames, $whereClause = '')
    {
        $isOnlyOneTable = ((strpos($tableNames, ',') === false)
            && (stripos(trim($tableNames), ' JOIN ') === false));
        if ($isOnlyOneTable && self::tableHasColumnUid($tableNames)) {
            // Counting only the "uid" column is faster than counting *.
            $columns = 'uid';
        } else {
            $columns = '*';
        }

        $result = self::selectSingle(
            'COUNT(' . $columns . ') AS phpunit_counter',
            $tableNames,
            $whereClause
        );

        return (int)$result['phpunit_counter'];
    }