Current location - Recipe Complete Network - Complete cookbook of home-style dishes - How does thinkphp realize the circular retrieval of secondary menu?
How does thinkphp realize the circular retrieval of secondary menu?
ThinkPHP realizes the secondary loop reading as follows:

$ Category = D(' Category ')-& gt; Where ('category _ PID = 0')->; findAll();

//dump($ Category);

If (! Empty($Category)){ // Judge whether the first level is empty.

foreach($ Category as $ key = & gt; $value){ // loop reading

$ PID = $ value[' category _ id ']; //field assignment

$ Category[$ key][' child ']= D(' Category ')-& gt; Where ("category _ PID = $ PID")->; select();

//echo D(' Category ')-& gt; getLastSql(); //Writing method of printing sql statement

}

}

//dump($ Category);

$ this-& gt; assign('Category ',$ Category); //Mapping value