/** * @param $tid * @param $postTable * @return unknown_type */ function addPostIndex($tid, $step) { $ptable = PostIndexDB::getPostTable($tid); $rt = $this->db->get_one("SELECT count(*) AS sum FROM {$ptable} p WHERE p.tid = " . S::sqlEscape($tid)); $count = $rt['sum']; !$step && ($step = 1); $next = $step + 1; $start = ($step - 1) * $this->p_c; $limit = S::sqlLimit($start, $this->p_c); $sql = "SELECT p.tid, p.pid, p.postdate, p.authorid\n\t\t\t\tFROM {$ptable} p\n\t\t\t\tWHERE p.tid = " . S::sqlEscape($tid) . " ORDER BY p.postdate {$limit}"; $query = $this->db->query($sql); while ($rt = $this->db->fetch_array($query)) { $f_data[] = array($rt["tid"], $rt["pid"]); } if (!empty($f_data)) { $this->db->update("REPLACE INTO pw_postsfloor(tid,pid) VALUES " . S::sqlMulti($f_data)); } $floor = $this->getMaxFloorByTid($tid); if ($count > $floor) { return $next; } else { #@cn0zz 添加索引完成后,才能修改帖子状态 //$sql = "UPDATE pw_threads SET tpcstatus = tpcstatus | 2 WHERE tid =".S::sqlEscape($tid); $sql = pwQuery::buildClause("UPDATE :pw_table SET tpcstatus = tpcstatus | 2 WHERE tid = :tid", array('pw_threads', $tid)); $this->db->update($sql); //* $threads = L::loadClass('Threads', 'forum'); //* $threads->delThreads($tid); return 0; } }