求帮助:Discuz数据库错误,提示如下,怎么解决?望高手指点
Discuz! Database Error
(1062) Duplicate entry '4' for key 'PRIMARY'
INSERT INTO auction_ovauctions SET `id`='4' , `uid`='4' , `atnnum`='ATN_201308041542338676' , `atntitle`='NGC MS 63九年精发' , `atncontent`='NGC MS 63九年精发' , `atnprice`='100' , `bidtype`='2' , `atntype`='11' , `bidcount`='0' , `qprice`='100' , `aprice`='5000' , `rprice`='4000' , `baotui`='1' , `tradtype`='1' , `fareprice`='' , `atnshtime`='1375602243' , `ovtime`='1375623686' , `atnyear`='' , `mainpic`='201308/04/154233naqborezf54q64pv.jpg' , `viewtimes`='84' , `favtimes`='0' , `bidtimes`='13' , `status`='2' , `bidnew`='385' , `shfr`='0' , `shse`='0' , `inputtime`='1375602153'
PHP Debug
No. File Line Code
1 home.php 41 require_once(%s)
2 source/module/home/home_auction.php 64 require_once(%s)
3 source/include/auction/auction_bidden.php 68 table_auction_ovauctions->add_ovacution(Array)
4 source/class/table/table_auction_ovauctions.php 16 discuz_database::insert(%s, Array, %d)
5 source/class/discuz/discuz_database.php 60 discuz_database::query(%s, %s, %s, false)
6 source/class/discuz/discuz_database.php 136 db_driver_mysql->query(%s, %s, false)
7 source/class/db/db_driver_mysql.php 151 db_driver_mysql->halt(%s, %d, %s)
8 source/class/db/db_driver_mysql.php 218 break()
回复讨论(解决方案)
你这张表没有,主键(自动增长)
把主键ID设置为自动增长
那怎么在数据库后台设置主键自动增长?
明显是主键有相同的值,在这里也就是在插入`id`='4' 时,表里已经有id=4的值了,所以重复了,不知道你的业务是什么,如果id是其他表的主键关联的话,建议在建立一个无关的自增的主键,而关联的id仅仅是这个表一个的字段。如果id不是其他表的主键关联的话,就不要设定主键的id值。