DanDaBeginner Posted April 19, 2007 Share Posted April 19, 2007 :-\ 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 Quote Link to comment Share on other sites More sharing options...
DanDaBeginner Posted April 19, 2007 Author Share Posted April 19, 2007 bump... Quote Link to comment Share on other sites More sharing options...
monk.e.boy Posted April 19, 2007 Share Posted April 19, 2007 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 Quote Link to comment Share on other sites More sharing options...
DanDaBeginner Posted April 20, 2007 Author Share Posted April 20, 2007 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? Quote Link to comment Share on other sites More sharing options...
neel_basu Posted April 20, 2007 Share Posted April 20, 2007 When you are retriving the texts from teh database. then use something like this if(mysql_num_rows(....) < 5) delete previous 2 rows. in that very scripts.e.g the same script will delete as well as retrive the values from database. Quote Link to comment Share on other sites More sharing options...
DanDaBeginner Posted April 21, 2007 Author Share Posted April 21, 2007 thanx guys... any more suggestion there? Quote Link to comment Share on other sites More sharing options...
DanDaBeginner Posted April 21, 2007 Author Share Posted April 21, 2007 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? Quote Link to comment Share on other sites More sharing options...
DanDaBeginner Posted April 21, 2007 Author Share Posted April 21, 2007 maybe barand you can help me on this one...hehehe! thanx Quote Link to comment Share on other sites More sharing options...
neel_basu Posted April 21, 2007 Share Posted April 21, 2007 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?Use microtime() Quote Link to comment Share on other sites More sharing options...
DanDaBeginner Posted April 21, 2007 Author Share Posted April 21, 2007 would it be possible? what you think? im using UNIX_TIMESTAMP() of mysql, i guess it also includes microtime...right? Quote Link to comment Share on other sites More sharing options...
neel_basu Posted April 21, 2007 Share Posted April 21, 2007 I dont think so. Quote Link to comment Share on other sites More sharing options...
DanDaBeginner Posted April 21, 2007 Author Share Posted April 21, 2007 I dont think so., to? Quote Link to comment Share on other sites More sharing options...
keeB Posted April 21, 2007 Share Posted April 21, 2007 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); } Quote Link to comment Share on other sites More sharing options...
DanDaBeginner Posted April 23, 2007 Author Share Posted April 23, 2007 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.