Jump to content

help with decision making...


DanDaBeginner

Recommended Posts

:-\ it seems that nobody are visiting the mysql help and thats whhy I posted it here.. sorry guys!

I made a chat that enables user to create a room with php,mysql,AJAX...

now my questio is:

 

I dont want to populate my table so what I did is instead inserting for every message in the table, what I did is Update for each room...am I right on this one? and also I deleted the room in the table when the creator of that room has no active activity or if the creator logsout? am I right on this one? or maybe delete the room if the room has no activity for about 1hour? what is the best.. nedd advice please..

 

thanx

Dan

Link to comment
Share on other sites

Hm, not sure really.

 

I would have a cron job that runs every minute that cleans out old messages from the database.

 

You can use a PHP script as the cron job.

 

Every message needs a time stamp (which I guess you are already doing) then delete those messages that are more than 3 days old.

 

You will have to keep an eye on the size of the database, if 1,000,000s of people are posting messages all day, then you may need to shorten the age of the messages so they get deleted sooner.

 

Does that help?

 

monk.e.boy

Link to comment
Share on other sites

:D thanx man... so its not a good idea to overwrite old message with the new message? instead of updating the row for that room, I can, maybe insert for every message then clean up afterwrads?

ANYONE PLEASE!!!!

 

 

and also when two user click's  the send button at the same time (accidentally, you will never know!), is there a possibility that they going to have a the same timestamp?

 

 

Link to comment
Share on other sites

bump for suggestion please... thanx in advance..

 

and also is there a chance that both user click the send button at the same time accidentally and save it to dbase, would they have the same timestamp?what I think is that they will not have the same timestamp, because mysql locks the insert while waiting for the first insert to be finish..am I right?

Link to comment
Share on other sites

pseudo-code


function clean_db($time) {
my_db->query("delete from chat where timestamp <= $time")
}

function post($chat) {
my_db->query("insert in to chat .. <insert code");
clean_db($whatever_threshold_you_decide);
}

 

 

Link to comment
Share on other sites

:) hi guys! bump for more please......thanx!

and also is there a chance that both user click the send button at the same time accidentally and save it to dbase, would they have the same timestamp?what I think is that they will not have the same timestamp, because mysql locks the insert while waiting for the first insert to be finish..am I right?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.