如何在gloccery crud中设置相对于另一个字段的唯一条目


how to set unique entry in glocery crud with respect to another field

我正试图通过在codeigniter中使用gloccery crud库在表中添加city。所以我用了一个函数

$crud->unique_fields('state');

它运行良好。但是,如果同一个州名称存在于不同的国家,该如何处理。我的数据库表是这样的

`id` `country_id`  `state`   `status`
 1     1             abc         0
 2     2             abc         0

您可以为此创建复合唯一密钥。

$crud->unique_fields('country_id', 'state');