简体   繁体   中英

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. 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. 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');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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