Welcome to Geeklog, Anonymous Wednesday, November 27 2024 @ 03:29 pm EST

Geeklog Forums

Timestamping Comments IDs


gizmozo

Anonymous
Hi,... Is there anyway to ID each comment entry as a timestamp (like the stories are "ID"ed) instead of 1, 2, 3, 4, etc.. I only ask because I'm a stickler for keeping my database "flowing." For example, with each story being IDed as a timestamp, if I deleted a story, the IDs would continue to be "flowing." If they were IDed as 1, 2, 3, 4 for example, then I deleted #3, in my database it would be 1, 2, 4 and to me that just seems wrong. Smile By IDing them as timestamps, I can delete any story without worrying about that. The comments "PID" however, is 1, 2, 3, 4 and so on. Is there anyway to ID them the same way as the stories (e.g. 2002011023232) so that if I delete comments, the "numerical chain" isn't broken? Same thing with user ID's too?
 Quote

Raveolution

Anonymous
If you used a database regulary, you would know that this behaviour is vital, it helps in mantaining consistency in the records of the database. If the database changed the id consistently when you delete a record it could mean a security breach and a huge bug. Imagine someone bookmarks a certain article (with ID and everything), if the user wanted to go back, the article would be gone and the user would be presented with the wrong one. I wouldn't recomend using the datestamp as ID because if two users post at the same time then you're in for major trouble. Your code would break and your database too. Don't worry about the ID. Keep on hacking.
 Quote

gizmozo

Anonymous
I don't mean a dynamically changing ID. The stories currently use datestamps to ID themselves, and those ID's don't change if you delete a story. I was just wondering if it was possible to do the same with individual comments and user ID's. Datestamps are also being used for events, links, etc. to ID them. Why not just use the datestamp for everything that needs to be IDed and keep things consistent?---Edwin Day http://www.gizmozo.com
 Quote

Raveolution

Anonymous
The ID used to identify the article use the following format (using is what i can determine, i haven't read the code) 20021215161031505 The first 14 chars are for the datestamp (ISO 8601): Year[4],Month[2],Day[2],Hour[2],Minute[2],Second[2] in this case : 20021215161031 or Sunday, December 15 @ 04:10 The chars after that are the actual ID of the article... in this case would be : 505 I believe the did this to prevent spam activity. I don't think it would be very difficult to use this kind of reference throughout the site... Hack Away Wink Good luck
 Quote

Status: offline

vinny

Site Admin
Admin
Registered: 06/24/02
Posts: 352
Location:Colorado, USA
Actually those last three numbers are randomly generated. The story id (event ids, etc) are generated by the COM_makesid() function in lib-common.php and are made up of the date string mentioned in the above comment appended with a random number from 0 - 999. The entire number (actually a text string in the database) is used as the primary key for the story. The comment table uses a completely different engine. As far as I know, there is not easy way to do what you want, but I don't think there is really need beyond URL ascetics. The database doesn't really care if a few numbers are missing. I'm sure you could change the comment engine to use the COM_makesid() function also, but it would require many changes to the code and at least one to the database... It is probably not worth it. -Vinny
 Quote

All times are EST. The time is now 03:29 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content