Php 嵌套集添加节点获取错误

Php 嵌套集添加节点获取错误,php,mysql,class,nested,nested-sets,Php,Mysql,Class,Nested,Nested Sets,我为php嵌套集使用一个类,当我想添加一个新节点时,我得到一个错误 Fatal error: Uncaught exception 'Exception' with message 'SafeMySQL: Duplicate entry '0' for key 'PRIMARY'. Full query: [INSERT INTO test_sections SET `section_name`='accebt',`section_left`='55',`section_right`='56',

我为php嵌套集使用一个类,当我想添加一个新节点时,我得到一个错误

Fatal error: Uncaught exception 'Exception' with message 'SafeMySQL: Duplicate entry '0' for key 'PRIMARY'. Full query: [INSERT INTO test_sections SET `section_name`='accebt',`section_left`='55',`section_right`='56',`section_level`='1']' in C:\xampp\htdocs\easy_b\shop_admin\db_tree\safemysql.class.php:607 Stack trace: #0 C:\xampp\htdocs\easy_b\shop_admin\db_tree\safemysql.class.php(429): SafeMySQL->error('Duplicate entry...') #1 C:\xampp\htdocs\easy_b\shop_admin\db_tree\safemysql.class.php(59): SafeMySQL->rawQuery('INSERT INTO tes...') #2 C:\xampp\htdocs\easy_b\shop_admin\db_tree\DbTree.class.php(215): SafeMySQL->query('INSERT INTO ?p ...', 'test_sections', Array) #3 C:\xampp\htdocs\easy_b\shop_admin\db_tree\examples\dbtree_demo.php(236): DbTree->Insert(0, Array) #4 {main} thrown in C:\xampp\htdocs\easy_b\shop_admin\db_tree\safemysql.class.php on line 607
我的代码是这样的,我搜索了错误,但什么也没找到,你能帮我吗?谢谢

public function Insert($parentId, $data = array(), $condition = '')
    {
        $node_info = $this->GetNode($parentId);

        $right_id = $node_info[$this->tableRight];
        $level = $node_info[$this->tableLevel];

        $condition = $this->PrepareCondition($condition);

        $sql = 'UPDATE ' . $this->table . ' SET ';
        $sql .= $this->tableLeft . '=CASE WHEN ' . $this->tableLeft . '>' . $right_id . ' THEN ' . $this->tableLeft . '+2 ELSE ' . $this->tableLeft . ' END, ';
        $sql .= $this->tableRight . '=CASE WHEN ' . $this->tableRight . '>=' . $right_id . ' THEN ' . $this->tableRight . '+2 ELSE ' . $this->tableRight . ' END ';
        $sql .= 'WHERE ' . $this->tableRight . '>=' . $right_id;
        $sql .= $condition;
        $this->db->query($sql);

        $data[$this->tableLeft] = $right_id;
        $data[$this->tableRight] = $right_id + 1;
        $data[$this->tableLevel] = $level + 1;

        $sql = 'INSERT INTO ?p SET ?u';
        $this->db->query($sql, $this->table, $data);

        $node_id = $this->db->insertId();

        return $node_id;
    }

我刚刚解决了我自己的问题,问题在DB中,我必须自动增加id。谢谢

我刚刚解决了我自己的问题,问题在DB中,我必须自动增加id。谢谢