Home >Backend Development >PHP Tutorial >Dedecms function sharing to get all sub-columns of a certain column_PHP tutorial
I have never written recursion before (actually, if I think about it, I have no idea about algorithms), I happened to have this need, so I tried to write it and found that it is quite easy. I will record it in particular.
The database is the default of dedecms, dede_arctype is the table that saves the column, and reid is the parent column id of the column.
var_dump($array);
function get_sons($type, &$current_array){
$result = mysql_query("select id from dede_arctype where reid = {$type}");
while($row = mysql_fetch_assoc($result) ){
$current_array[] = $row['id'];
get_sons($row['id'], $current_array);
}
}