Files
crm.clientright.ru/scripts/show_channels.php
Fedor 01c4fe80b5 chore: snapshot current working tree changes
Save all currently accumulated repository changes as a backup snapshot for Gitea so no local work is lost.
2026-03-26 14:19:01 +03:00

63 lines
1.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* Показать все используемые значения channel в vtiger_modcomments
* Вызов: https://crm.clientright.ru/scripts/show_channels.php
*/
error_reporting(E_ALL);
ini_set('display_errors', '1');
header('Content-Type: text/plain; charset=utf-8');
chdir(dirname(__DIR__));
require_once 'config.inc.php';
$mysqli = new mysqli($dbconfig['db_hostname'], $dbconfig['db_username'], $dbconfig['db_password'], $dbconfig['db_name']);
$mysqli->set_charset('utf8');
if ($mysqli->connect_error) {
die("Ошибка подключения: " . $mysqli->connect_error);
}
echo "Используемые значения channel в vtiger_modcomments:\n";
echo str_repeat('=', 70) . "\n\n";
$result = $mysqli->query("
SELECT channel, COUNT(*) as count
FROM vtiger_modcomments
WHERE channel IS NOT NULL AND channel != ''
GROUP BY channel
ORDER BY count DESC
");
if (!$result) {
die("Ошибка запроса: " . $mysqli->error);
}
if ($result->num_rows === 0) {
echo "❌ Нет записей с заполненным channel.\n";
} else {
echo "Найдено уникальных значений: {$result->num_rows}\n\n";
printf("%-30s %10s\n", "Channel", "Количество");
echo str_repeat('-', 42) . "\n";
while ($row = $result->fetch_assoc()) {
printf("%-30s %10d\n", $row['channel'], $row['count']);
}
}
echo "\n" . str_repeat('=', 70) . "\n";
// Также покажем NULL значения
$result2 = $mysqli->query("
SELECT COUNT(*) as count
FROM vtiger_modcomments
WHERE channel IS NULL OR channel = ''
");
if ($result2 && $result2->num_rows > 0) {
$row = $result2->fetch_assoc();
echo "\nКомментариев без channel (NULL или пустая строка): {$row['count']}\n";
}
$mysqli->close();