Get the App
SLTechnology News&Howtos  ›  Development  › 

How to recursively delete a node and all nodes under that node

Shulou Source: shulou.com Published: 2022-06-03 07:49:40 11月15日 Update

This article mainly introduces "how to recursively delete a node and all nodes under that node". In daily operation, it is believed that many people have doubts about how to recursively delete a node and all nodes under that node. The editor consulted all kinds of materials and sorted out simple and useful operation methods. I hope it will be helpful to answer the question of "how to recursively delete a node and all nodes under that node"! Next, please follow the editor to study!

The copy code is as follows:

/ *

* modify a piece of department information

, /

Function del ($bumen_id) {

$sql= "select bumen_id from lxsm_bumen where topbumen_id=". $bumen_id; / / query bumen_id with topbumen_id as $bumen_id

$delsql= "delete from lxsm_bumen where bumen_id=". $bumen_id; / / Delete department information whose bumen_id is $bumen_id

$xiaji_id=$this- > DB- > fetch_assoc ($sql)

If ($xiaji_id) {

Foreach ($xiaji_id as $id) {

$res=$this- > del ($id [bumen _ id])

}

}

$result=$this- > DB- > query ($delsql)

If ($result) {

Return true

}

Else {

Return false

}

}

Note: the topbumen_id here is the id number of the superior department in the department information, and the fetch_assoc () function is an encapsulated function that returns all the contents of the query into an array.

At this point, the study on "how to recursively delete a node and all nodes under that node" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Nodes recursion departments learning information code functions more help query utility next superiors content arrays articles methods comments theory knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno NVidia MariaDB Apple Microsoft