static function getSettings() { $db = DbModel::getInstance(); $db->query('SELECT * from settings'); $db->stmt->execute(); return $db->single(); }
public function deleteTopPost($toppostid) { $db = DbModel::getInstance(); // First delete all childs of this toppost $db->query('DELETE FROM posts WHERE post_relation_id = :id '); $db->bind(':id', $toppostid); $db->stmt->execute(); // Now delete the toppost itself $db->query('DELETE FROM posts WHERE id = :id '); $db->bind(':id', $toppostid); $db->stmt->execute(); if ($db->rowCount() === 1) { // Remove the views file $filename = BASE_URI . 'views/' . $toppostid . '.txt'; if (unlink($filename)) { // Views file is deleted as well as the toppost return true; } else { // Views file is not deleted (toppost also) return false; } } else { // Views file is not deleted (toppost also) return false; } }
static function getAllUsersPerPage($offset, $per_page) { $db = DbModel::getInstance(); $db->query('SELECT * from users WHERE disabled != 1 LIMIT :per_page OFFSET :offset'); $db->bind(':per_page', $per_page); $db->bind(':offset', $offset); $db->stmt->execute(); return $db->resultSet(); }
static function countCategories() { $db = DbModel::getInstance(); $db->query('SELECT COUNT(*) FROM categories'); $db->stmt->execute(); $result = $db->single(); return $result['COUNT(*)']; }