function __construct($config = NULL) { $this->debug = false; $this->ID = 65535; $this->root = array(); //$this->openMysql(); $this->db = GCDB::getInstance($config); $this->getArray(); }
public static function deleteThreadTypeSFun($tid) { if (!is_numeric($tid)) { echo "deleteThreadType请输入正确的参数<br/>"; return false; } //获取数据库操作实例 $db = GCDB::getInstance(); $db->start_transaction(); $sql = "DELETE FROM `{$db->tablepre}forum_gc_excellent_thread` WHERE tid={$tid};"; if (!$db->query($sql)) { echo "数据库操作失败,删除分类失败<br/>"; $db->rollback_transaction(); return false; } $db->commit_transaction(); return true; }
public static function deleteAllThreadWithMainType($type_id) { $reslut = self::isMainType($type_id); if ($reslut[0]) { //正确获取分类信息 if (!$reslut['ismaintype']) { //是次分类,则直接返回正确 return array('0' => true, 'type' => 'subordinate'); } else { //是主分类,则需要删除数据库 $db = GCDB::getInstance(); $sql = "SELECT `tid` FROM `{$db->tablepre}forum_gc_excellent_thread` WHERE `type_id`={$type_id};"; $sqldata = $db->query($sql); if (!$sqldata) { return array('0' => false, 'message' => "查询数据库失败"); } while ($row = $sqldata->fetch_assoc()) { $tid = $row['tid']; $sql = "DELETE FROM `{$db->tablepre}forum_gc_excellent_thread` WHERE `tid`={$tid};"; if ($db->query($sql) == false) { return array('0' => false, 'message' => "删除数据库出错"); } } return array('0' => true, 'type' => 'maintype'); } } else { return array('0' => false, 'message' => "未查找到该分类信息"); } }
public static function beCategoried($tid) { //若参数不是数字,则报错 if (!is_numeric($tid)) { //echo "参数错误<br/>"; return array(intval(-1), "参数错误"); } //查找数据库 $db = GCDB::getInstance(); $sql = "SELECT type_id,rate FROM `{$db->tablepre}forum_gc_excellent_thread` WHERE tid={$tid};"; //echo "sql:{$sql}"; $sqldata = $db->query($sql); if (!$sqldata) { //echo "查询数据库出错<br/>"; return array(intval(-1), "数据库查询错误sql:" . $sql); } $row = $sqldata->fetch_assoc(); if (empty($row)) { //没有分类 return array(false, "未找到该分类"); } //已分类 $tree = DataTree::getInstance(); $type_array = array(); $type_array[0] = array(); $type_array[0]['type_id'] = $row['type_id']; $type_array[0]['rate'] = $row['rate']; $type_array[0]['type_name'] = $tree->getOneTreeNode($row['type_id'])->type_name; $i = 1; while ($row = $sqldata->fetch_assoc()) { $type_array[$i]['type_id'] = $row['type_id']; $type_array[$i]['rate'] = $row['rate']; $type_array[$i]['type_name'] = $tree->getOneTreeNode($row['type_id'])->type_name; $i += 1; } return array(true, $type_array); }