private function deleteOneNode(&$node) { if (empty($node)) { return; } //为空则直接返回null //先删除其所有子节点 $rightflag = true; foreach ($node->child as $value) { $rightflag &= $this->deleteOneNode($value); } //若子类任意一个删除错误,则直接返回错误,不进行自身删除 if (!$rightflag) { return false; } //先删除其分类节点上的帖子关系 if ($node->type_level != 0) { CenterGradation::deleteAllThreadWithMainType($node->type_id); } //再删除本节点 $sql = "DELETE FROM `{$this->tablepre}forum_gc_type_thread` WHERE `type_id`=" . $node->type_id . ";"; $sqldata = $this->mysqli->query($sql); if (!$sqldata) { var_dump($sqldata); return false; //throw new Exception("Database Error [{$this->database->errno}] {$this->database->error}"); } //都正确,则返回true; return true; //更新到对象 //unset($node); //$node=NULL; //更新到数组 //unset($this->data_array[$node->type_id]); //$this->data_array[$node->type_id]=NULL; }
if ($result[ismaintype]) { echo "是主分类<br/>"; } else { echo "是次分类(非主分类)<br/>"; } } else { echo $result['message'] . "<br/>"; } echo "2、删除主分类关联信息:"; /* * INSERT INTO `gcdiscuzforum_forum_gc_excellent_thread`( `tid`, `type_id`, `rate`) VALUES (3,55,NUll),(3,56,NULL); * 56是主分类 * 55是次分类 */ $type_id = 56; $result = CenterGradation::deleteAllThreadWithMainType($type_id); print_r($result); echo "<br/><font color=#FF0004'>测试文件运行完成</font>"; //include template("excellent_shared/excellent_setting"); /* function getOneTypeTreeNodeFormDB($type_id){ $type_tree=array(); $sql = "SELECT `type_id`,`type_name` FROM `gcdiscuzforum_forum_gc_type_thread` WHERE `type_level`=0"; $sqldata=DB::query($sql); $data=DB::fetch($sqldata); $trans=0; $type_tree[$trans]=new DataTreeNode(NULL,$data['type_id'],$data['type_name'],0); //获取子节点 $sql = "SELECT b.father_type_id AS \'father_type_id\',\n" . " c.type_id AS \'type_id\',c.type_name as \'type_name\', \n" . " c.type_level AS \'type_level\' \n"