Hi, Im a beginner to OOP in PHP.
I’m trying to make a forum, but don’t know what classes to make. I though of making an abstract class called thread, is this correct? I don’t know what methods to give it though.
Cheers.
Hi, Im a beginner to OOP in PHP.
I’m trying to make a forum, but don’t know what classes to make. I though of making an abstract class called thread, is this correct? I don’t know what methods to give it though.
Cheers.
http://stackoverflow.com/questions/4175078/a-thread-topic-class-in-php
Already asking this question in the same guise, elsewhere.
I asked there afterwards…after waiting on this dead forum, atleast I got a meaningful reply there…
Instead of someone stating the obvious.
I’m not sure if you are putting the cart before the horse here.
I assume you have already designed your ERD and built your database from it.
Imho, you need to have your database finalised first because either directly or indirectly the rest of your code “sits on top” of it.
Think of the database as being the foundations of a house. If the foundation isn’t there or is faulty, then the house will soon fall down.
Post your ERD from which it will be easier to see what classes and methods within those classes you will need.
Hi,
I have the following entities:
Threads, Replies and Author
One Thread can have many replies (Thread_Replies), one author can have many threads (Author_Threads), and an author can also have many replies (Author_Replies)…
Threads ----> Thread_Replies <----- Replies
(Threads has one to many relationship with Thread_Replies)
Author -----> Replies <------ Thread_Replies
I did draw a ERD, but it was on paper. Hopefully the picture below will be a little clearer (showcasing my amazing paint skills):
http://imageupper.com/i/?S0100010050011D2897458601652474
Also I would like to apologise to the previous poster, was a bit rude there ^, I’m just trying to get my head around OOP. Forgive me .
Wouldn’t this do?
thread
id
title
content
author_id
created_on
author
id
name
reply
id
content
thread_id
author_id
Database normalization my friend. Otherwise you would end up with anamolies such as this:
-source: http://en.wikipedia.org/wiki/Database_normalization
I don’t see how.
thread shouldnt really have any content, imo, and instead ‘replies’ is actually ‘posts’, a thread being a collection of posts. (Will make it easier if you try to search posts, instead of having to cross-table to check the initial post’s text)
I’d love to continue this discussion, but I fear it isn’t really what the OP originally asked for.
I think I’ll start a thread in the Database forum, just so I can prove how thick I am.
By different Authors though, what would you do if you wanted to search posts by a certain Author.
A post has an author. A thread does not. (A thread’s ‘original author’ is defined to be the author of the lowest ID post belonging to said thread)
How do i search posts by author? In MySQL Code… SELECT * FROM posts WHERE author_id = $targetedauthorid
You should checkout the “Designer” tab in phpMyAdmin