Home > Article > Backend Development > Example explanation of ThinkPHP+EasyUI
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!