简体   繁体   English

如何在Codeigniter中使用杂货杂货实现关系?

[英]How to implement a relation using grocery crud in codeigniter?

I'm using codeigniter and grocery crud. 我正在使用Codeigniter和杂货杂货。 I'm having a trouble in implementing a dropdownlist. 我在实现下拉列表时遇到了麻烦。 When I add a data in the deduction table what I want to do is display all employee names which can be determined by having an entry in employee table. 当我在扣除表中添加数据时,我想要做的是显示所有员工名称,这些名称可以通过在employee表中有一个条目来确定。 Once the name is selected, on saving, it should save the employeeID which can be obtained from the employee table. 选择名称后,在保存时,应保存可以从employee表中获取的employeeID。 Your help will be appreciated, thank you in advance. 感谢您的帮助,在此先感谢您。

关系表

For your deduction table: 对于您的扣除表:

$crud->set_relation('employeeID','employee','employeeID'); $ crud-> set_relation('employeeID','employee','employeeID');

This should go into your deductions controller you will receive a dropdown that displays employeeID and the objects those ids belong to. 这应该进入您的扣除控制器,您将收到一个下拉列表,其中显示了employeeID和这些ID所属的对象。

For your employee table 为您的员工表

$crud->set_relation('employeeID','member',memberID); $ crud-> set_relation('employeeID','member',memberID);

This should go into employee controller you will receive a dropdown that displays employeeID and the objects those ids belong to. 这应该进入员工控制器,您将收到一个下拉列表,其中显示了employeeID和这些ID所属的对象。

Hope this helps. 希望这可以帮助。

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

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