Best way to save information to database

199 views
Skip to first unread message

simonr...@gmail.com

unread,
Aug 8, 2014, 11:00:21 AM8/8/14
to ratch...@googlegroups.com
Hi,

I am developing a live chat application based on symfony2.

In order to keep track of previous conversations and to do some statistics, i would like to save in db (mysql currently) some informations, like session id, messages sent, chat duration and so on... on connection close.

Then, onOpen, I'd like to check if previous chat for the user exists, and display the messages.

I would like to know to your opinion what is the best way to save informations in database ? I read that mysql could block the connection. There is a better way to do that ?

attozk

unread,
Aug 13, 2014, 10:46:13 AM8/13/14
to ratch...@googlegroups.com

I am doing exactly that for my chat application and using https://github.com/bixuehujin/reactphp-mysql which is non-blocking.

You may want to do a bulk inserts though by, say, storing messages to a buffer array, when it reaches 50-100 flush them into db. 

kitar...@gmail.com

unread,
Feb 18, 2016, 6:17:55 PM2/18/16
to Ratchet
Hi attozk,

Do you mind sharing a basic code on how to put all together? I'm new in Ratchet and I'm burning many hours trying to understand.... I also have my messages on a db... I want to add the instant private message but I need to keep saving those on the db. I have my users log in to the website and they sign up using sessions...

Thanks
Reply all
Reply to author
Forward
0 new messages