cleaned up the code
This commit is contained in:
parent
bf27d735fe
commit
984d44ac75
@ -6,7 +6,12 @@ class DBBoard extends Database{
|
|||||||
$con = self::connectToDB();
|
$con = self::connectToDB();
|
||||||
$query = $con->prepare("SELECT * FROM board");
|
$query = $con->prepare("SELECT * FROM board");
|
||||||
$query->execute();
|
$query->execute();
|
||||||
return $query->fetchAll(PDO::FETCH_BOTH);
|
$boardArray = [];
|
||||||
|
while($result = $query->fetch(PDO::FETCH_BOTH)){
|
||||||
|
$board = new Board($result['ID'],$result['name'],$result['permLevel']);
|
||||||
|
array_push($boardArray, $board);
|
||||||
|
}
|
||||||
|
return $boardArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -25,7 +25,12 @@ class DBThread extends Database {
|
|||||||
$query = $con->prepare("SELECT * FROM thread WHERE board_ID = :boardID");
|
$query = $con->prepare("SELECT * FROM thread WHERE board_ID = :boardID");
|
||||||
$query->bindParam(":boardID", $boardID);
|
$query->bindParam(":boardID", $boardID);
|
||||||
$query->execute();
|
$query->execute();
|
||||||
return $query->fetchAll(PDO::FETCH_BOTH);
|
$threadArray = [];
|
||||||
|
while($result = $query->fetch(PDO::FETCH_BOTH)){
|
||||||
|
$thread = new Thread($result['ID'], $result['users_ID'], $result['board_ID'], $result['title'], $result['text'], $result['date_created']);
|
||||||
|
array_push($threadArray, $thread);
|
||||||
|
}
|
||||||
|
return $threadArray;
|
||||||
}
|
}
|
||||||
static function createThread($threadObject){
|
static function createThread($threadObject){
|
||||||
$con = self::connectToDB();
|
$con = self::connectToDB();
|
||||||
|
|||||||
@ -8,6 +8,15 @@ class Board {
|
|||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->permLevel = $permLevel;
|
$this->permLevel = $permLevel;
|
||||||
}
|
}
|
||||||
|
function getId(){
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
function getName(){
|
||||||
|
return $this->$name;
|
||||||
|
}
|
||||||
|
function getPermLevel(){
|
||||||
|
return $this->$permLevel;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,35 +7,19 @@ require_once ROOT_DIR.'/model/forum/Thread.php';
|
|||||||
require_once ROOT_DIR.'/model/forum/User.php';
|
require_once ROOT_DIR.'/model/forum/User.php';
|
||||||
require_once ROOT_DIR.'/model/forum/Reply.php';
|
require_once ROOT_DIR.'/model/forum/Reply.php';
|
||||||
|
|
||||||
$boardTable = DBBoard::getBoards();
|
$boards = DBBoard::getBoards();
|
||||||
$threadsTable = [];
|
|
||||||
$usersTable = [];
|
|
||||||
$boards = [];
|
|
||||||
$threads = [];
|
|
||||||
$users = [];
|
$users = [];
|
||||||
foreach ($boardTable as $row)
|
$threads = [];
|
||||||
|
$threadUsers = [];
|
||||||
|
foreach ($boards as $board)
|
||||||
{
|
{
|
||||||
$threadsTable = array_merge($threadsTable, DBThread::getThreadsByBoard($row['ID']));
|
$threads = array_merge($threads, DBThread::getThreadsByBoard($board->getId()));
|
||||||
array_push($boards, new Board($row['ID'], $row['name'], $row['permLevel']));
|
|
||||||
}
|
}
|
||||||
foreach($threadsTable as $row)
|
foreach($threads as $thread)
|
||||||
{
|
{
|
||||||
|
array_push($users, DBUser::getUserByUID($thread->getUserID()));
|
||||||
|
}
|
||||||
|
|
||||||
array_push($threads, new Thread($row['ID'],$row['users_ID'],$row['board_ID'],$row['title'],$row['text'],$row['date_created']));
|
|
||||||
array_push($usersTable, DBUser::getUserByUID($row['users_ID']));
|
|
||||||
|
|
||||||
}
|
|
||||||
foreach($usersTable as $row){
|
|
||||||
$skipUser = false;
|
|
||||||
foreach($users as $user){
|
|
||||||
if($row->getId() == $user->getId()){
|
|
||||||
$skipUser = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!$skipUser){
|
|
||||||
array_push($users, $row);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user