diff --git a/functions/post.php b/functions/post.php index 8519d43..a6df40a 100644 --- a/functions/post.php +++ b/functions/post.php @@ -267,7 +267,7 @@ class Thought extends Post $this->thought = $thought; if ($id < 0) { - $stmt = 'INSERT INTO post (id, parentSpace, creator, postType, status, thought) VALUES (?, ?, ?, ?, ?, ?)'; + $stmt = 'INSERT INTO post (id, space, creator, postType, status, thought) VALUES (?, ?, ?, ?, ?, ?)'; parent::setId($id * -1); $space = isset($space) ? $space->getId() : $creator->getHomeSpace()->getId(); exec_stmt($stmt, 'iiiiis', $id * -1, $space, $creator->getId(), 3, 2, $this->thought); diff --git a/functions/space.php b/functions/space.php index 630072b..32e5d29 100644 --- a/functions/space.php +++ b/functions/space.php @@ -27,7 +27,7 @@ class Space $this->id = $id * -1; error_log('ID: ' . $this->id); - $stmt = 'INSERT INTO space (id, name, description, visibility, parentSpace) VALUES (?, ?, ?, ?, ?)'; + $stmt = 'INSERT INTO space (id, name, description, visibility, parent) VALUES (?, ?, ?, ?, ?)'; exec_stmt($stmt, 'issii', $this->id, $name, $description, $visibility, (isset($parent) ? $parent->getId() : null)); error_log('Added space in DB'); } else @@ -57,13 +57,12 @@ class Space public function getSubSpaces(): ?array { - $stmt = 'SELECT id FROM space WHERE parentSpace = ?'; + $stmt = 'SELECT id FROM space WHERE parent = ?'; $rawSubSpaces = exec_stmt($stmt, 'i', $this->id); $subSpaces = []; - foreach ($rawSubSpaces as $ss) { + foreach ($rawSubSpaces as $ss) $subSpaces[] = Space::retrieveFromDB($ss['id']); - } return $subSpaces; } @@ -136,8 +135,8 @@ class Space $rawSpace = exec_stmt($stmt, 'i', $space)->fetch_assoc(); if ($rawSpace) { - if (!empty($rawSpace['parentSpace'])) - $parent = Space::retrieveFromDB($rawSpace['parentSpace'], $user); + if (!empty($rawSpace['parent'])) + $parent = Space::retrieveFromDB($rawSpace['parent'], $user); else $parent = null; @@ -147,7 +146,7 @@ class Space foreach ($rawMembers as $m) $members[] = User::retrieveFromDB($m['user']); - $stmt = 'SELECT post FROM spacePosts INNER JOIN post ON spacePosts.post = post.id WHERE space = ? ORDER BY post.createdAt DESC'; + $stmt = 'SELECT post FROM spacePosts INNER JOIN post ON spacePosts.post = post.id WHERE spacePosts.space = ? ORDER BY post.createdAt DESC'; $posts = []; $rawPosts = exec_stmt($stmt, 'i', $rawSpace['id']); while ($row = $rawPosts->fetch_assoc())