This repository has been archived on 2024-07-18. You can view files and clone it, but cannot push or open issues or pull requests.
lwb5/scripts/game/main/forums/library/getTopic.inc

37 lines
809 B
PHP
Raw Normal View History

2016-01-10 11:01:49 +01:00
<?php
class main_forums_getTopic {
function main_forums_getTopic($lib) {
$this->lib = $lib;
$this->db = $this->lib->game->db;
}
function run($tid) {
// Get main topic data
$q = $this->db->query(
"SELECT t.id AS id,p.title AS title,"
. "p.id AS fpid,t.last_post AS lpid,"
. "f.id AS fid,f.title AS fname,"
. "c.id AS cid,c.title AS cname "
. "FROM f_topic t,f_post p,f_forum f,f_category c "
. "WHERE t.id=$tid AND p.id=t.first_post "
. "AND f.id=t.forum AND c.id=f.category "
. "AND t.deleted IS NULL"
);
if (!$q || dbCount($q) != 1) {
return null;
}
$rv = dbFetchHash($q);
// Get post count
$q = $this->db->query("SELECT COUNT(*) FROM f_post WHERE topic=$tid AND deleted IS NULL");
list($rv["nitems"]) = dbFetchArray($q);
return $rv;
}
}
?>