framework icon indicating copy to clipboard operation
framework copied to clipboard

TP6 使用 unique 更新时验证数据项目唯一性提示重复

Open gyjcode opened this issue 2 years ago • 1 comments

image 如题,在更新数据时因为数据包含 code 值,使用 unique 验证唯一性会提示重复,查看 think/Validate 下的源码文件,发现 getPk() 函数获取的主键为 null.

gyjcode avatar Oct 02 '22 02:10 gyjcode

image Query 类这里,打印了两次,第二次应该是查询数据库中没有设置主键,所以把主键置空了。我的数据表使用 PHPMyAdmin 导出又导入的,导出的时候不知道为什么把主键设置与自增属性,唯一性等都给去除了。应该是这个原因导致的。

gyjcode avatar Oct 02 '22 03:10 gyjcode

模型主键 Model::$pk 支持手动设置,其它问题在平时使用暂未复现

big-dream avatar Feb 26 '24 02:02 big-dream