Home >Backend Development >PHP Tutorial >Example explanation of ThinkPHP+EasyUI

Example explanation of ThinkPHP+EasyUI

零下一度
零下一度Original
2017-06-23 14:19:023508browse

Assume that the fields of the accounting data table in the database are: id, code, name, islast. They are the auto-increment primary key, account code, account name, and whether it is the last-level account ("1" indicates the last-level account). Here, recursion is used in the model layer of Thinkphp to build the data required by ComboTree. The code and annotations are as follows:

 AccountModel   = ->field('id,code,name,islast')->(  & = (['code'( == 3['pid'] = 0['pid'] = (['code'],0,-2 ->createTree(  createSubTree(, = (  =>(['pid'] ==  = 'id' => ['id'],
                    'text'=>['name'],
                    'state'=>(['islast'] != 1)?'closed':'open'(['islast'] != 1 = ->createSubTree(,['code'(!(['children'] = (,   createTree( = (   => (['pid'] == 0 = 'id' => ['id'],
                    'text'=>['name'],
                    'state'=>'closed' = ->createSubTree(,['code'(!(['children'] = [] =

Data similar to the above (such as departments, regions, etc.) need to build a tree shape Similar functions can basically be achieved by simply modifying the menu code.

The above is the detailed content of Example explanation of ThinkPHP+EasyUI. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn