M
M
mapleart2017-10-11 08:08:43
PHP
mapleart, 2017-10-11 08:08:43

How to implement the deletion of correspondence in the chat?

Hello. I wrote a small chat for my project. With the ability to create conferences. This is what the DB looks like:

CREATE TABLE `prefix_chat_room` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `admin_id` int(11) NOT NULL ,
  `type` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `prefix_chat_message` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
  `room_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `answer_to` int(11) NOT NULL DEFAULT '0',
  `message` text NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `prefix_chat_room_relation` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `room_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `message_id` int(11) NOT NULL DEFAULT '0'
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Now I want to implement the ability to delete a chat... If I delete the entire chat, I'll add, for example, the delete_id field to the prefix_chat_room_relation table and show only those messages whose id is greater than delete_id.
And if you do deletion by messages, how to make sure that messages are not deleted from other participants in the correspondence?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
synapse_people, 2017-10-11
@mappleart

Make 2 flags who has already deleted and who has not on prefix_chat_message

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question