Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: bobdole2281 - syyskuu 06, 2013, 10:32:33 AP

Otsikko: What is the field "id_last_msg" in smf_topics?
Kirjoitti: bobdole2281 - syyskuu 06, 2013, 10:32:33 AP
I'm trying to understand what the field id_last_msg is on the table smf_topics.

Here is an example:

id_last_msg
2878
150
...

Does that represent the ID of a post or some kind of time period when the post was made?
Otsikko: Re: What is the field "id_last_msg" in smf_topics?
Kirjoitti: Arantor - syyskuu 06, 2013, 10:34:02 AP
Shock horror... maybe it's the id of the last message in the topic as referencing smf_messages...?
Otsikko: Re: What is the field "id_last_msg" in smf_topics?
Kirjoitti: margarett - syyskuu 06, 2013, 10:58:40 AP
Trying to be a little more specific...

All your posts are stored in the table "smf_messages". The topics (the post that starts a topic) are referenced in the table "smf_topics" (not the post itself, kind of a "pointer" to the post in). In each topic you have a "last post", whose ID is pointed out in that field. Easy, right? ;)

If I might ask, what are you trying to do? Or just navigating the DB?
Otsikko: Re: What is the field "id_last_msg" in smf_topics?
Kirjoitti: Colin - syyskuu 06, 2013, 11:51:21 AP
It is used to quickly display the last message of the thread on the board index and thread index. It also is used for the last message link.
Otsikko: Re: What is the field "id_last_msg" in smf_topics?
Kirjoitti: Arantor - syyskuu 06, 2013, 11:52:25 AP
It's used for more than that, too. It's actually used to calculate whether a topic has unread messages or not.
Otsikko: Re: What is the field "id_last_msg" in smf_topics?
Kirjoitti: bobdole2281 - syyskuu 06, 2013, 11:57:59 AP
Lainaus käyttäjältä: margarett - syyskuu 06, 2013, 10:58:40 AP
Trying to be a little more specific...

All your posts are stored in the table "smf_messages". The topics (the post that starts a topic) are referenced in the table "smf_topics" (not the post itself, kind of a "pointer" to the post in). In each topic you have a "last post", whose ID is pointed out in that field. Easy, right? ;)

If I might ask, what are you trying to do? Or just navigating the DB?

I found what I was looking for.

Just trying to better understand. It definitely wasn't what I thought. It does a lot more than I thought as well.

Thanks for the replies guys.
Otsikko: Re: What is the field "id_last_msg" in smf_topics?
Kirjoitti: Arantor - syyskuu 06, 2013, 11:59:21 AP
I'm not being funny but what did you think it might be?

The columns are, by and large, well named. If you have something in the topics table that's called 'id_last_msg', is it not totally logical it should be the id of the last message in the topic? Just as id_first_msg is the id of the first message in the topic... just as num_replies is the number of replies in the topic.
Otsikko: Re: What is the field "id_last_msg" in smf_topics?
Kirjoitti: bobdole2281 - syyskuu 06, 2013, 04:34:14 IP
I wasn't sure if each message had it's own ID. I assumed that's what it was, but I found it strange there was no poster_time like in the smf_messages.

Now I know though, learning new stuff everyday.
Otsikko: Re: What is the field "id_last_msg" in smf_topics?
Kirjoitti: Arantor - syyskuu 06, 2013, 04:35:50 IP
Why would the topic have a poster time? The topic has a collection of messages, there's no way a single poster time would work for it?

The topic is a collection of messages, the messages have times. smf_messages does quite clearly have an id, id_msg.