[英]How to create organization structure using codeigniter and json
I have task to create a organization structure from database using codeigniter and json. 我的任务是使用codeigniter和json从数据库创建组织结构。 I got constraint.
我有约束。 the script isn't working.
该脚本不起作用。
Are there any suggestions for create it?? 有什么建议吗?
This is my database (organization) : 这是我的数据库(组织):
- table_org id urutan name title 1 1 aaaa Head of Logistic 2 2 bbbbbb Division Logistic 3 3 ccccccc Staff/Employees, etc...
View : <body> <div id="people"></div> <script type="text/ecmascript"> var readUrl = "http://localhost/Codeg/struktur_org/"; $.getJSON(readUrl, function(people) { $('#people').getOrgChart({ theme: "helen", primaryColumns: ["name", "title"], imageColumn: "image", linkType: "M", editable: false, dataSource: people }); }); </script> </body>
Controller : <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); //we need to call PHP's session object to access it through CI class Struktur_org extends CI_Controller { function __construct() { parent::__construct(); $this->load->model('struktur_model'); } public function index()//may be index() or something else.Rename this funciton name as yours { echo json_encode( $this->struktur_model->getMember() ); $this->load->view('struktur_org'); } }
Model : <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Struktur_model extends CI_Model { function __construct() { parent::__construct(); } function getMember(){ $query = $this->db->get('org'); return $query; } }
Yor second column should be parrent ID. 您的第二列应该是父母ID。 Here is an example
这是一个例子
- table_org id urutan name title 1 null aaaa Head of Logistic 2 1 bbbbbb Division Logistic 3 1 ccccccc Staff/Employees, etc...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.