[英]how to set unique entry in glocery crud with respect to another field
I am trying to add city in a table by using glocery crud library in codeigniter. 我试图通过在codeigniter中使用glocery crud库在表中添加城市。 So i use a function
所以我使用一个功能
$crud->unique_fields('state');
which is working fine . 工作正常。 But how to handle if same state_name exist in different countrystate.
但是,如果不同国家/地区存在相同的state_name,该如何处理。 My database table is like this
我的数据库表是这样的
`id` `country_id` `state` `status`
1 1 abc 0
2 2 abc 0
您可以为此创建复合唯一密钥。
$crud->unique_fields('country_id', 'state');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.