Commit 9d855c35 authored by Armando Lüscher's avatar Armando Lüscher Committed by GitHub

Merge pull request #378 from jacklul/username_in_chat_table

Add 'username' field to 'chat' table
parents b12b2e99 bfb2a3e7
...@@ -408,18 +408,20 @@ class DB ...@@ -408,18 +408,20 @@ class DB
$chat_id = $chat->getId(); $chat_id = $chat->getId();
$chat_title = $chat->getTitle(); $chat_title = $chat->getTitle();
$chat_username = $chat->getUsername();
$chat_type = $chat->getType(); $chat_type = $chat->getType();
$chat_all_members_are_administrators = $chat->getAllMembersAreAdministrators(); $chat_all_members_are_administrators = $chat->getAllMembersAreAdministrators();
try { try {
$sth = self::$pdo->prepare(' $sth = self::$pdo->prepare('
INSERT IGNORE INTO `' . TB_CHAT . '` INSERT IGNORE INTO `' . TB_CHAT . '`
(`id`, `type`, `title`, `all_members_are_administrators`, `created_at` ,`updated_at`, `old_id`) (`id`, `type`, `title`, `username`, `all_members_are_administrators`, `created_at` ,`updated_at`, `old_id`)
VALUES VALUES
(:id, :type, :title, :all_members_are_administrators, :date, :date, :oldid) (:id, :type, :title, :username, :all_members_are_administrators, :date, :date, :oldid)
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
`type` = :type, `type` = :type,
`title` = :title, `title` = :title,
`username` = :username,
`all_members_are_administrators` = :all_members_are_administrators, `all_members_are_administrators` = :all_members_are_administrators,
`updated_at` = :date `updated_at` = :date
'); ');
...@@ -436,6 +438,7 @@ class DB ...@@ -436,6 +438,7 @@ class DB
$sth->bindParam(':type', $chat_type, PDO::PARAM_INT); $sth->bindParam(':type', $chat_type, PDO::PARAM_INT);
$sth->bindParam(':title', $chat_title, PDO::PARAM_STR, 255); $sth->bindParam(':title', $chat_title, PDO::PARAM_STR, 255);
$sth->bindParam(':username', $chat_username, PDO::PARAM_STR, 255);
$sth->bindParam(':all_members_are_administrators', $chat_all_members_are_administrators, PDO::PARAM_INT); $sth->bindParam(':all_members_are_administrators', $chat_all_members_are_administrators, PDO::PARAM_INT);
$sth->bindParam(':date', $date, PDO::PARAM_STR); $sth->bindParam(':date', $date, PDO::PARAM_STR);
......
...@@ -14,6 +14,7 @@ CREATE TABLE IF NOT EXISTS `chat` ( ...@@ -14,6 +14,7 @@ CREATE TABLE IF NOT EXISTS `chat` (
`id` bigint COMMENT 'Unique user or chat identifier', `id` bigint COMMENT 'Unique user or chat identifier',
`type` ENUM('private', 'group', 'supergroup', 'channel') NOT NULL COMMENT 'Chat type, either private, group, supergroup or channel', `type` ENUM('private', 'group', 'supergroup', 'channel') NOT NULL COMMENT 'Chat type, either private, group, supergroup or channel',
`title` CHAR(255) DEFAULT '' COMMENT 'Chat (group) title, is null if chat type is private', `title` CHAR(255) DEFAULT '' COMMENT 'Chat (group) title, is null if chat type is private',
`username` CHAR(255) DEFAULT NULL COMMENT 'Username, for private chats, supergroups and channels if available',
`all_members_are_administrators` tinyint(1) DEFAULT 0 COMMENT 'True if a all members of this group are admins', `all_members_are_administrators` tinyint(1) DEFAULT 0 COMMENT 'True if a all members of this group are admins',
`created_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date creation', `created_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date creation',
`updated_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date update', `updated_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date update',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment