[英]How to allow null on foreign key column in mysql php?
I have mysql table users
.我有 mysql 表
users
。 In the registration form country is compulsory but district is not compulsory.在注册表中,国家是强制性的,但地区不是强制性的。 Both are foreign key column.
两者都是外键列。
So some user keep empty the district field.所以一些用户保持空区字段。 Than what & how should i pass
district_id
from ajax, if district is blank?如果 District 是空白的,那么我应该如何从 ajax 传递
district_id
?
I have already set null the district_id
null & passing "null" value for district_id
column.我已经将
district_id
设置为 null 并为district_id
列传递“null”值。 But error is incorrect integer value for district_id
column.但错误是
district_id
列的不正确整数值。
Pls.请。 suggest an idea.
提出一个想法。
如果表字段已经用“NULL”属性检查过,只是你没有向该列传递任何值
a primary key cannot be null.主键不能为空。 You can create a "special" record in district table to represent a value when there is not value setted from user.
当用户没有设置值时,您可以在区表中创建一个“特殊”记录来表示一个值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.