简体   繁体   English

如何在 codeigniter 中为用户创建分层树结构?

[英]how can I create a hierarchical tree structure for users in codeigniter?

For eg.例如。 Admin creates a user 'A' then A is the child user of admin, then if 'A' creates a user 'B' then 'B' is the child user of A. Admin 创建一个用户 'A' 那么 A 是 admin 的子用户,那么如果 'A' 创建一个用户 'B' 那么 'B' 是 A 的子用户。

使用 ion_auth 库非常完整安全,并使用组结构...

I am not sure what this has to do with CodeIgniter, but a normal solution is to have an additional column that is labelled something like 'parent_id' and contains the id of the parent.我不确定这与 CodeIgniter 有什么关系,但正常的解决方案是有一个附加的列,该列标记为“parent_id”之类的内容并包含父项的 id。 In that way you can run a query to get all the children of a parent, then all the grand-children of those children etc etc using the parent ID in the lookup.通过这种方式,您可以运行查询以获取父级的所有子级,然后使用查找中的父级 ID 获取这些子级的所有孙子级等等。 Since this is heavily dependent on your actual usage, set up, and is quite extensive involving views, controllers, css, models (perhaps) and table design, it is not really possible to give you example CI code.由于这在很大程度上取决于您的实际使用、设置,并且涉及视图、控制器、css、模型(可能)和表设计,因此无法为您提供示例 CI 代码。

What have you done so far, what code have you got, can you narrow down your problem to a single aspect, like creating a tree view, or identifying child and grandchild of an element, or writing a query to collect the data etc. The more focus your question has the better we can help you.到目前为止你做了什么,你有什么代码,你能不能把你的问题缩小到一个方面,比如创建一个树视图,或者识别一个元素的子元素和孙元素,或者编写一个查询来收集数据等等。您的问题越集中,我们就越能帮助您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM