如何在特定记录范围内使用is_unique表单验证?

时间:2017-04-26 13:35:17

标签: php codeigniter

我有一个名为@mixin dynamic-bg($path, $type, $ext, $source-list) { @each $source in $source-list { &[data-bg="#{$source}"] { background: url($path + $source + '_' + $type + '.' + $ext) no-repeat; } } } a { @include dynamic-bg($path, "logo", "png", ("alpha", "beta", "gamma")); } strong { @include dynamic-bg($path, "logo", "png", ("strong-1", "strong-2")); } 的表格:

participants

创建参与者的规则是每个注册的电子邮件地址只能参加一个锦标赛(外键CREATE TABLE IF NOT EXISTS `participants` ( `id` int(8) NOT NULL AUTO_INCREMENT, `email` varchar(30) NOT NULL, `name` varchar(40) NOT NULL, `birthdate` date NOT NULL, `personal_number` varchar(16) DEFAULT NULL, `phone` varchar(16) NOT NULL, `photo` varchar(100) NOT NULL, `address` text NOT NULL, `city_id` int(3) DEFAULT NULL, `tournament_id` int(8) NOT NULL, `time_created` datetime NOT NULL, `time_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `city_id` (`city_id`), KEY `tournament_id` (`tournament_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; );因此两个记录具有相同的电子邮件地址但不同的 tournament_id允许

tournament_id表单验证是否能够执行此操作?或者我应该创建一个回调或帮助?

1 个答案:

答案 0 :(得分:1)

is_unique只是value_does_not_already_exists_in_a_single_column的简称。

所以,不,它不会胜任这项工作;你需要回电。