![]() |
Having an issue with the forum..
Yea, here we go again ;)
I've come a good bit. I already have a user system that I've built before, that I'm planning on implanting, so I'm mainly concentrating on getting the forum functions right now. For example, categories, forums in different categories, and threads. Now I have a question. My database structure looks like this: Code:
forums => I think you understand the basics about the forum table. If a forum is a category, the row is the value 1, if it's a simple forum it's a 0. If it's a regular forum, the "parent" row is set with the forum_id of the category forum that it's supposed to be under. The thread table is quite easy aswell. My question concerns the POSTS in the threads. Should I store them inside the thread table(?? :S), or should I create a seperate table for the posts, like this? Code:
posts => |
In my personal opinion, the answer to your question is yes. Forum software like Invision Power Board and phpBB (any maybe even vBulliten) do this method. I also plan on doing it this way when I start to build my own forum.
Hope that helps! |
Okey, thank you! Do you have any suggestions about the forum and thread db structure? Does it look good? Can it be done better?
|
I'm confused!
You have tinyint(10) but the highest tinyint you can get is an unsigned tinyint which is 225 digits max. :\ |
In extension to bdm's comment, you should never use tinyint for an ID unless you know there will never be more than 255 (unsigned) IDs. It's also important to understand unsigned, by making a number "unsigned" you prohibit negative values and effectively double the amount of valid IDs that you can store in a single field.
|
Quote:
|
Make any ID fields unsigned, for example, consider your current thread_forumId field, which is of type tinyint.
As it currently stands, that field can hold 255 values: -128 to 127. However, by making that specific field unsigned, we change that range to 0-255, thus giving us another 128 possible IDs. The same applies for most (if not all?) numeric data types. |
So in your case, I'd say it's safe to use unsigned tinyint.
Now that I think about, I have yet to see a forums have anywhere close to 255 forums+categories. Just another decision you must make. :-) Also, in your threads table, you should replace thread_author with author_id or something along those lines. Where author_id will link to your users table. threads ... author_id (FK) | | users | | user_id (PK) ... Also, shouldn't the thread_sticky column from the threads table be a bit or even tinyint(1)? |
What's unsigned? :S
|
Quote:
It's also important to understand unsigned, by making a number "unsigned" you prohibit negative values and effectively double the amount of valid IDs that you can store in a single field. |
Oh, you edited your post above my last post :D
Anyways, thanks for the tip about the author, much better, so big thanks :D And yes, sticky could be only 1, since it's only 1 number.. :) And the "unsigned", I change that in phpmyadmin huh?? :-) |
Quote:
|
Quote:
|
Mhm, now I'm having another problem...
php Code:
And then this: php Code:
It inserts the data, and it echoes out that "reply posted". I check the thread, but the post isn't there! So I check the database, and sure enough, the post EXISTS in the posts table. But the "post_thread" row value is set to 0 for some reason. So it's.. yea, no idea what's wrong :S |
Anyone? =//
|
Quote:
|
Like dschreck said, we'd need to see all of the code that's being used to insert a new post.
|
You already see all the code? :S
newpost.php php Code:
forum.php (the class) php Code:
showthread.php php Code:
|
Oh.
Code:
<form action="newpost.php" method="POST">Code:
<form action="newpost.php?t=<?=$_GET['t'];?>" method="POST"> |
Quote:
I didn't think I needed that number, but thanks :D |
| All times are GMT. The time now is 06:35 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0