Thinkphp, as an open source PHP framework, has developed to this day. It is undoubtedly the most suitable framework for PHP students to learn and use in China. In addition to being simple and easy to use, the greater advantage is the complete development documentation and rich plug-ins. To meet the conditions for developing a large and medium-sized website framework, "ThinkPHP5 Mall Project Practical Video Tutorial" will take the development of a medium-sized mall as an example and lead you to learn the core technology of Thinkphp.
Course playback address: http://www.php.cn/course/546.html
The teacher’s teaching style:
The teacher’s lectures are vivid, witty, witty, and touching. A vivid metaphor is like the finishing touch, opening the door to wisdom for students; a well-placed humor brings a knowing smile to students, like drinking a glass of mellow wine, giving people aftertaste and nostalgia; a philosopher's aphorisms, cultural references Proverbs are interspersed from time to time in the narration, giving people thinking and warning.
The more difficult point in this video is the design of the ThinkPHP infinite classification module:
Infinite classification and single classification are supported. Addition, deletion, modification and query are based on ThinkPHP operations. If you You can just change your own database operations. The module itself should not write the data layer in the module, but my project classification basically includes these operations, such as addition, deletion, modification, and search, so I wrote it directly in it. I didn’t want to Repeatedly write the code for adding, deleting, modifying, and checking.
I have also uploaded two tables here. Just change the table prefix to your own. This code of test.php can be used directly in one of the methods of a certain class in your project Lib.
public function catelist(){ $cate=D('Cate'); //var_dump($cate->gettree());exit; $cateres=$cate->gettree(); $this->assign('cateres',$cateres); $this->display(); }
The above is a very common database display api operation. Just display the database data. To design unlimited classification, first define a gettree method in the model layer
//商品分类中查询的公共方法---无限分类 public function gettree($p = 0,$lv = 0){ $t = array(); //循环打印数据表里面的数据,此时循环出来的是一个个一维数组 foreach ($this->select() as $k => $v) { //检查此时的数据的parent_id是否=0 if($v['parent_id'] == $p){ //子栏目缩进 $v['lv'] = $lv; //把数组赋值给$t $t[] = $v; //检查.合并array_merge $t = array_merge($t,$this->gettree($v['cate_id'],$lv+1)); } } return $t; }
Here we also recommend downloading source code resources:http://www.php.cn/xiazai/ learn/2118
1.3_Courseware
2.Source code
The above is the detailed content of ThinkPHP5 mall project practical video tutorial courseware source code sharing. For more information, please follow other related articles on the PHP Chinese website!