다음과 같은 테이블이 있습니다 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
되어야한다 허용 .
가 is_unique
양식 유효성 검사는이 작업을 할 수? 아니면 콜백이나 도우미를 만들어야합니까?
is_unique
의 짧은 이름입니다 value_does_not_already_exists_in_a_single_column
.
그래서, 아닙니다 – 그것은 일을하지 않을 것입니다; 콜백이 필요합니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다